Skip to content

Commit f4058bc

Browse files
committed
Adding frontend_css and js in configurations
1 parent 2548916 commit f4058bc

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

docs/reference/advanced_configuration.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ Full configuration options:
4242
stylesheets:
4343
# Defaults:
4444
- bundles/sonatapage/app.css
45-
- bundles/sonatapage/frontend.css
4645
javascripts:
46+
frontend_stylesheets:
47+
# Defaults:
48+
- bundles/sonatapage/frontend.css
49+
frontend_javascripts:
4750
templates: # Required
4851
# Prototype
4952
id:

docs/reference/installation.rst

+7
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ SonataPageBundle Configuration
121121
not_found: [404] # render 404 page with "not_found" key (name generated: _page_internal_error_{key})
122122
fatal: [500] # so you can use the same page for different http errors or specify specific page for each error
123123
124+
# Add custom css and js for your pages.
125+
# assets:
126+
# frontend_javascripts:
127+
# - js/your.js
128+
# frontend_stylesheets:
129+
# - css/your.css
130+
124131
SonataAdminBundle Configuration
125132
-------------------------------
126133

src/DependencyInjection/Configuration.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,23 @@ public function getConfigTreeBuilder(): TreeBuilder
138138
->arrayNode('stylesheets')
139139
->defaultValue([
140140
'bundles/sonatapage/app.css',
141-
'bundles/sonatapage/frontend.css',
142141
])
143142
->prototype('scalar')->end()
144143
->end()
145144
->arrayNode('javascripts')
146145
->defaultValue([])
147146
->prototype('scalar')->end()
148147
->end()
148+
->arrayNode('frontend_stylesheets')
149+
->defaultValue([
150+
'bundles/sonatapage/frontend.css',
151+
])
152+
->prototype('scalar')->end()
153+
->end()
154+
->arrayNode('frontend_javascripts')
155+
->defaultValue([])
156+
->prototype('scalar')->end()
157+
->end()
149158
->end()
150159
->end()
151160

src/Resources/views/base_layout.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ file that was distributed with this source code.
2121

2222
{% block sonata_page_stylesheets %}
2323
{% block page_stylesheets %} {# Deprecated block #}
24-
{% for stylesheet in sonata_page.assets.stylesheets %}
24+
{% for stylesheet in sonata_page.assets.frontend_stylesheets %}
2525
<link rel="stylesheet" href="{{ asset(stylesheet) }}" media="all">
2626
{% endfor %}
2727
{% endblock %}
@@ -34,7 +34,7 @@ file that was distributed with this source code.
3434
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
3535
<![endif]-->
3636

37-
{% for js in sonata_page.assets.javascripts %}
37+
{% for js in sonata_page.assets.frontend_javascripts %}
3838
<script src="{{ asset(js) }}"></script>
3939
{% endfor %}
4040
{% endblock %}

tests/DependencyInjection/ConfigurationTest.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,12 @@ public function testPageWithMatrix(): void
124124
'assets' => [
125125
'stylesheets' => [
126126
'bundles/sonatapage/app.css',
127-
'bundles/sonatapage/frontend.css',
128127
],
129128
'javascripts' => [],
129+
'frontend_stylesheets' => [
130+
'bundles/sonatapage/frontend.css',
131+
],
132+
'frontend_javascripts' => [],
130133
],
131134
'templates_admin' => [
132135
'list' => '@SonataPage/PageAdmin/list.html.twig',
@@ -194,9 +197,12 @@ public function testPageWithoutMatrix(): void
194197
'assets' => [
195198
'stylesheets' => [
196199
'bundles/sonatapage/app.css',
197-
'bundles/sonatapage/frontend.css',
198200
],
199201
'javascripts' => [],
202+
'frontend_stylesheets' => [
203+
'bundles/sonatapage/frontend.css',
204+
],
205+
'frontend_javascripts' => [],
200206
],
201207
'templates_admin' => [
202208
'list' => '@SonataPage/PageAdmin/list.html.twig',

0 commit comments

Comments
 (0)