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
7e554db2
Commit
7e554db2
authored
Feb 18, 2013
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved the performance of the Twig loader by not registering a chain loader if not needed
parent
c421eab3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
src/Silex/Provider/TwigServiceProvider.php
src/Silex/Provider/TwigServiceProvider.php
+1
-1
tests/Silex/Tests/Provider/TwigServiceProviderTest.php
tests/Silex/Tests/Provider/TwigServiceProviderTest.php
+14
-0
No files found.
src/Silex/Provider/TwigServiceProvider.php
View file @
7e554db2
...
...
@@ -96,8 +96,8 @@ class TwigServiceProvider implements ServiceProviderInterface
$app
[
'twig.loader'
]
=
$app
->
share
(
function
(
$app
)
{
return
new
\Twig_Loader_Chain
(
array
(
$app
[
'twig.loader.filesystem'
],
$app
[
'twig.loader.array'
],
$app
[
'twig.loader.filesystem'
],
));
});
}
...
...
tests/Silex/Tests/Provider/TwigServiceProviderTest.php
View file @
7e554db2
...
...
@@ -63,4 +63,18 @@ class TwigServiceProviderTest extends \PHPUnit_Framework_TestCase
$response
=
$app
->
handle
(
$request
);
$this
->
assertEquals
(
'foo'
,
$response
->
getContent
());
}
public
function
testLoaderPriority
()
{
$app
=
new
Application
();
$app
->
register
(
new
TwigServiceProvider
(),
array
(
'twig.templates'
=>
array
(
'foo'
=>
'foo'
),
));
$loader
=
$this
->
getMock
(
'\Twig_LoaderInterface'
);
$loader
->
expects
(
$this
->
never
())
->
method
(
'getSource'
);
$app
[
'twig.loader.filesystem'
]
=
$app
->
share
(
function
(
$app
)
use
(
$loader
)
{
return
$loader
;
});
$this
->
assertEquals
(
'foo'
,
$app
[
'twig.loader'
]
->
getSource
(
'foo'
));
}
}
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