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
12bb71b2
Commit
12bb71b2
authored
Mar 26, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a way for extension to automatically register autoloading rules
parent
cda8dce8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
src/Silex/Application.php
src/Silex/Application.php
+9
-0
src/Silex/TwigExtension.php
src/Silex/TwigExtension.php
+4
-0
No files found.
src/Silex/Application.php
View file @
12bb71b2
...
...
@@ -29,6 +29,7 @@ use Symfony\Component\Routing\RouteCollection;
use
Symfony\Component\Routing\Matcher\UrlMatcher
;
use
Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException
;
use
Symfony\Component\Routing\Matcher\Exception\NotFoundException
;
use
Symfony\Component\ClassLoader\UniversalClassLoader
;
/**
* The Silex framework class.
...
...
@@ -44,9 +45,17 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
{
$sc
=
$this
;
$this
[
'autoloader'
]
=
$this
->
asShared
(
function
()
{
$loader
=
new
UniversalClassLoader
();
$loader
->
register
();
return
$loader
;
});
$this
[
'routes'
]
=
$this
->
asShared
(
function
()
{
return
new
RouteCollection
();
});
$this
[
'controllers'
]
=
$this
->
asShared
(
function
()
use
(
$sc
)
{
return
new
ControllerCollection
(
$sc
[
'routes'
]);
});
...
...
src/Silex/TwigExtension.php
View file @
12bb71b2
...
...
@@ -25,5 +25,9 @@ class TwigExtension implements ExtensionInterface
$app
[
'twig.loader'
]
=
$app
->
asShared
(
function
()
use
(
$app
)
{
return
new
\Twig_Loader_Filesystem
(
$app
[
'twig.path'
]);
});
if
(
isset
(
$app
[
'twig.class_path'
]))
{
$app
[
'autoloader'
]
->
registerPrefix
(
'Twig_'
,
$app
[
'twig.class_path'
]);
}
}
}
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