Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
9c56d19f
Commit
9c56d19f
authored
Jun 15, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed the twig.configure service
parent
9766faf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
doc/changelog.rst
doc/changelog.rst
+16
-1
doc/providers/twig.rst
doc/providers/twig.rst
+13
-4
src/Silex/Provider/TwigServiceProvider.php
src/Silex/Provider/TwigServiceProvider.php
+1
-1
No files found.
doc/changelog.rst
View file @
9c56d19f
Changelog
=========
This changelog references all backward incompatibilities as we introduce them:
* **2012-06-15**: removed the ``twig.configure`` service. Use the ``extend``
method instead:
Before::
$app['twig.configure'] = $app->protect(function ($twig) use ($app) {
// do something
});
After::
$app['twig'] = $app->extend('twig', function($twig, $app) {
// do something
return $twig;
});
* **2012-06-13**: Added a route ``before`` middleware
...
...
doc/providers/twig.rst
View file @
9c56d19f
...
...
@@ -25,10 +25,6 @@ Services
* **twig**: The ``Twig_Environment`` instance. The main way of
interacting with Twig.
* **twig.configure**: :doc:`Protected closure </services#protected-closures>`
that takes the Twig environment as an argument. You can use it to add more
custom globals.
* **twig.loader**: The loader for Twig templates which uses the ``twig.path``
and the ``twig.templates`` options. You can also replace the loader
completely.
...
...
@@ -118,5 +114,18 @@ from a template:
{# or if you are also using UrlGeneratorServiceProvider with the SymfonyBridgesServiceProvider #}
{{ render(path('sidebar')) }}
Customization
-------------
You can configure the Twig environment before using it by extending the
``twig`` service::
$app['twig'] = $app->extend('twig', function($twig, $app) {
$twig->addGlobal('pi', 3.14);
$twig->addFilter('levenshtein', new \Twig_Filter_Function('levenshtein'));
return $twig;
});
For more information, check out the `Twig documentation
<http://twig.sensiolabs.org>`_.
src/Silex/Provider/TwigServiceProvider.php
View file @
9c56d19f
...
...
@@ -74,7 +74,7 @@ class TwigServiceProvider implements ServiceProviderInterface
}
if
(
isset
(
$app
[
'twig.configure'
]))
{
$app
[
'twig.configure'
](
$twig
);
throw
new
\RuntimeException
(
'The twig.configure service has been removed. Read the changelog to learn how you can upgrade your code.'
);
}
return
$twig
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment