Commit 63e660fa authored by Fabien Potencier's avatar Fabien Potencier

added more docs

parent acf60818
...@@ -481,3 +481,13 @@ Traits ...@@ -481,3 +481,13 @@ Traits
$user = $app->user(); $user = $app->user();
$encoded = $app->encodePassword($user, 'foo'); $encoded = $app->encodePassword($user, 'foo');
``Silex\Route\SecurityTrait`` adds the following methods to the controllers:
* **secure**: Secures a controller for the given roles.
.. code-block:: php
$app->get('/', function () {
// do something but only for admins
})->secure('ROLE_ADMIN');
...@@ -741,15 +741,14 @@ after every chunk:: ...@@ -741,15 +741,14 @@ after every chunk::
Traits Traits
------ ------
Silex comes with PHP traits that add some shortcut methods to your Application Silex comes with PHP traits that define shortcut methods.
class.
.. caution:: .. caution::
You need to use PHP 5.4 or later to benefit from this feature. You need to use PHP 5.4 or later to benefit from this feature.
Almost all built-in service providers have a corresponding PHP trait. To use Almost all built-in service providers have some corresponding PHP traits. To
them, define your own application and include the traits you want:: use them, define your own Application class and include the traits you want::
use Silex\Application; use Silex\Application;
...@@ -764,6 +763,20 @@ them, define your own application and include the traits you want:: ...@@ -764,6 +763,20 @@ them, define your own application and include the traits you want::
use Application\TranslationTrait; use Application\TranslationTrait;
} }
You can also define your own Route class and use some traits::
use Silex\Route;
class MyRoute extends Route
{
use Route\SecurityTrait;
}
To use your newly defined route, override the ``$app['route_class']``
setting::
$app['route_class'] = 'MyRoute';
Read each provider chapter to learn more about the added methods. Read each provider chapter to learn more about the added methods.
Security Security
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment