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
49ffb755
Commit
49ffb755
authored
Apr 03, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[docs] some documentation for the UrlGeneratorExtension
parent
cc4b5758
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
doc/extensions.rst
doc/extensions.rst
+1
-0
doc/extensions/index.rst
doc/extensions/index.rst
+1
-0
doc/extensions/url_generator.rst
doc/extensions/url_generator.rst
+51
-0
No files found.
doc/extensions.rst
View file @
49ffb755
...
@@ -34,6 +34,7 @@ All of these are within the ``Silex\Extension`` namespace.
...
@@ -34,6 +34,7 @@ All of these are within the ``Silex\Extension`` namespace.
* :doc:`MonologExtension <extensions/monolog>`
* :doc:`MonologExtension <extensions/monolog>`
* :doc:`TwigExtension <extensions/twig>`
* :doc:`TwigExtension <extensions/twig>`
* :doc:`UrlGeneratorExtension <extensions/url_generator>`
Creating an extension
Creating an extension
---------------------
---------------------
...
...
doc/extensions/index.rst
View file @
49ffb755
...
@@ -6,3 +6,4 @@ Silex
...
@@ -6,3 +6,4 @@ Silex
monolog
monolog
twig
twig
url_generator
doc/extensions/url_generator.rst
0 → 100644
View file @
49ffb755
UrlGenerator
============
The *UrlGeneratorExtension* provides a service for generating
URLs for named routes.
Parameters
----------
None.
Services
--------
* **url_generator**: An instance of
``Symfony\Component\Routing\Generator\UrlGenerator``, using the
``RouteCollection`` that is provided through the ``routes`` service.
It has a ``generate`` method, which takes the route name as an argument,
followed by an array of route parameters.
Registering
-----------
::
use Silex\Extension\UrlGeneratorExtension;
$app->register(new UrlGeneratorExtension());
Usage
-----
The UrlGenerator extension provides a ``url_generator`` service.
::
$app->get('/', function() {
return 'welcome to the homepage';
})
->bind('homepage');
$app->get('/hello/{name}', function($name) {
return "Hello $name!";
})
->bind('hello');
$app->get('/navigation', function() use ($app) {
return '<a href="'.$app['url_generator']->generate('homepage').'">Home</a>'.
' | '.
'<a href="'.$app['url_generator']->generate('hello', array('name' => 'Igor')).'">Hello Igor</a>';
});
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