Commit 929d327d authored by Fabien Potencier's avatar Fabien Potencier

added some missing use statements in the security docs (closes #445)

parent 4bd46b80
...@@ -176,6 +176,8 @@ Always keep in mind the following two golden rules: ...@@ -176,6 +176,8 @@ Always keep in mind the following two golden rules:
For the login form to work, create a controller like the following:: For the login form to work, create a controller like the following::
use Symfony\Component\HttpFoundation\Request;
$app->get('/login', function(Request $request) use ($app) { $app->get('/login', function(Request $request) use ($app) {
return $app['twig']->render('login.html', array( return $app['twig']->render('login.html', array(
'error' => $app['security.last_error']($request), 'error' => $app['security.last_error']($request),
...@@ -390,7 +392,7 @@ Using an array of users is simple and useful when securing an admin section of ...@@ -390,7 +392,7 @@ Using an array of users is simple and useful when securing an admin section of
a personal website, but you can override this default mechanism with you own. a personal website, but you can override this default mechanism with you own.
The ``users`` setting can be defined as a service that returns an instance of The ``users`` setting can be defined as a service that returns an instance of
`UserProvider `UserProviderInterface
<http://api.symfony.com/master/Symfony/Component/Security/Core/User/UserProviderInterface.html>`_:: <http://api.symfony.com/master/Symfony/Component/Security/Core/User/UserProviderInterface.html>`_::
'users' => $app->share(function () use ($app) { 'users' => $app->share(function () use ($app) {
...@@ -405,7 +407,6 @@ store the users:: ...@@ -405,7 +407,6 @@ store the users::
use Symfony\Component\Security\Core\User\User; use Symfony\Component\Security\Core\User\User;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Table;
class UserProvider implements UserProviderInterface class UserProvider implements UserProviderInterface
{ {
...@@ -450,6 +451,8 @@ class must implement `UserInterface ...@@ -450,6 +451,8 @@ class must implement `UserInterface
And here is the code that you can use to create the database schema and some And here is the code that you can use to create the database schema and some
sample users:: sample users::
use Doctrine\DBAL\Schema\Table;
$schema = $conn->getSchemaManager(); $schema = $conn->getSchemaManager();
if (!$schema->tablesExist('users')) { if (!$schema->tablesExist('users')) {
$users = new Table('users'); $users = new Table('users');
...@@ -507,7 +510,7 @@ use in your configuration:: ...@@ -507,7 +510,7 @@ use in your configuration::
You can now use it in your configuration like any other built-in You can now use it in your configuration like any other built-in
authentication provider:: authentication provider::
$app->register(new SecurityServiceProvider(), array( $app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array( 'security.firewalls' => array(
'default' => array( 'default' => array(
'wsse' => true, 'wsse' => true,
......
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