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
63e660fa
Commit
63e660fa
authored
Jun 19, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more docs
parent
acf60818
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
doc/providers/security.rst
doc/providers/security.rst
+10
-0
doc/usage.rst
doc/usage.rst
+17
-4
No files found.
doc/providers/security.rst
View file @
63e660fa
...
@@ -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');
doc/usage.rst
View file @
63e660fa
...
@@ -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
...
...
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