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
53f39cfa
Commit
53f39cfa
authored
Aug 29, 2015
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed code as url_generator is now always available
parent
2179d540
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
15 deletions
+12
-15
doc/services.rst
doc/services.rst
+2
-2
doc/usage.rst
doc/usage.rst
+4
-4
src/Silex/Provider/SecurityServiceProvider.php
src/Silex/Provider/SecurityServiceProvider.php
+1
-1
src/Silex/Provider/TwigServiceProvider.php
src/Silex/Provider/TwigServiceProvider.php
+1
-4
tests/Silex/Tests/Application/UrlGeneratorTraitTest.php
tests/Silex/Tests/Application/UrlGeneratorTraitTest.php
+4
-4
No files found.
doc/services.rst
View file @
53f39cfa
...
...
@@ -245,7 +245,7 @@ Core parameters
Defaults to 80.
This parameter can be used
by the ``UrlGeneratorProvider``
.
This parameter can be used
when generating URLs
.
* **request.https_port** (optional): Allows you to override the default port
for HTTPS URLs. If the current request is HTTPS, it will always use the
...
...
@@ -253,7 +253,7 @@ Core parameters
Defaults to 443.
This parameter can be used
by the ``UrlGeneratorProvider``
.
This parameter can be used
when generating URLs
.
* **debug** (optional): Returns whether or not the application is running in
debug mode.
...
...
doc/usage.rst
View file @
53f39cfa
...
...
@@ -389,9 +389,9 @@ have the value ``index``.
Named Routes
~~~~~~~~~~~~
Some providers
(such as ``UrlGeneratorProvider``) can make use of named routes.
By default Silex will generate an internal route name for you but you can give
an explicit route name by calling
``bind``::
Some providers
can make use of named routes. By default Silex will generate an
internal route name for you but you can give an explicit route name by calling
``bind``::
$app->get('/', function () {
// ...
...
...
@@ -625,7 +625,7 @@ round-trip to the browser (as for a redirect), use an internal sub-request::
.. tip::
If you are using ``UrlGeneratorProvider``, you can also generate the URI
::
You can also generate the URI via the built-in URL generator
::
$request = Request::create($app['url_generator']->generate('hello'), 'GET');
...
...
src/Silex/Provider/SecurityServiceProvider.php
View file @
53f39cfa
...
...
@@ -335,7 +335,7 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
};
$app
[
'security.http_utils'
]
=
function
(
$app
)
{
return
new
HttpUtils
(
isset
(
$app
[
'url_generator'
])
?
$app
[
'url_generator'
]
:
null
,
$app
[
'request_matcher'
]);
return
new
HttpUtils
(
$app
[
'url_generator'
]
,
$app
[
'request_matcher'
]);
};
$app
[
'security.last_error'
]
=
$app
->
protect
(
function
(
Request
$request
)
{
...
...
src/Silex/Provider/TwigServiceProvider.php
View file @
53f39cfa
...
...
@@ -67,10 +67,7 @@ class TwigServiceProvider implements ServiceProviderInterface
if
(
class_exists
(
'Symfony\Bridge\Twig\Extension\RoutingExtension'
))
{
$twig
->
addExtension
(
new
HttpFoundationExtension
(
$app
[
'request_stack'
]));
if
(
isset
(
$app
[
'url_generator'
]))
{
$twig
->
addExtension
(
new
RoutingExtension
(
$app
[
'url_generator'
]));
}
if
(
isset
(
$app
[
'translator'
]))
{
$twig
->
addExtension
(
new
TranslationExtension
(
$app
[
'translator'
]));
...
...
tests/Silex/Tests/Application/UrlGeneratorTraitTest.php
View file @
53f39cfa
...
...
@@ -21,16 +21,16 @@ class UrlGeneratorTraitTest extends \PHPUnit_Framework_TestCase
public
function
testUrl
()
{
$app
=
new
UrlGeneratorApplication
();
$app
[
'url_generator'
]
=
$t
ranslator
=
$t
his
->
getMockBuilder
(
'Symfony\Component\Routing\Generator\UrlGeneratorInterface'
)
->
disableOriginalConstructor
()
->
getMock
();
$
translator
->
expects
(
$this
->
once
())
->
method
(
'generate'
)
->
with
(
'foo'
,
array
(),
true
);
$app
[
'url_generator'
]
=
$this
->
getMockBuilder
(
'Symfony\Component\Routing\Generator\UrlGeneratorInterface'
)
->
disableOriginalConstructor
()
->
getMock
();
$
app
[
'url_generator'
]
->
expects
(
$this
->
once
())
->
method
(
'generate'
)
->
with
(
'foo'
,
array
(),
true
);
$app
->
url
(
'foo'
);
}
public
function
testPath
()
{
$app
=
new
UrlGeneratorApplication
();
$app
[
'url_generator'
]
=
$t
ranslator
=
$t
his
->
getMockBuilder
(
'Symfony\Component\Routing\Generator\UrlGeneratorInterface'
)
->
disableOriginalConstructor
()
->
getMock
();
$
translator
->
expects
(
$this
->
once
())
->
method
(
'generate'
)
->
with
(
'foo'
,
array
(),
false
);
$app
[
'url_generator'
]
=
$this
->
getMockBuilder
(
'Symfony\Component\Routing\Generator\UrlGeneratorInterface'
)
->
disableOriginalConstructor
()
->
getMock
();
$
app
[
'url_generator'
]
->
expects
(
$this
->
once
())
->
method
(
'generate'
)
->
with
(
'foo'
,
array
(),
false
);
$app
->
path
(
'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