Closed tineo closed 9 years ago
Have you defined your own Route class as described in http://silex.sensiolabs.org/doc/usage.html#traits ?
Closing as there is no feedback from reporter.
Sorry guys but I'm facing the same issue but i will send you more info. I'm not using my own routes but, I'm using bind functions, but I used bind functions with assets and everything works fine. So the issue is this
'BadMethodCallException' with message 'Method "Silex\Route::secure" does not exist.' in vendor/silex/silex/src/Silex/Controller.php:90
Stack trace:
#0 Silex\Controller->__call('secure', Array)
#1 Silex\Controller->secure('ROLE_ADMIN')
#2 {main}
thrown in /vendor/silex/silex/src/Silex/Controller.php on line 90
My code
$app->get('/auth/documentos', function(Request $request) use ($app)
$token = $app['security.token_storage']->getToken();
if ($token !== null) {
if ($token->getUsername() === 'qwerty' && $token->isAuthenticated()) {
return $app['twig']->render('documentos.html');
} else {
return $app->abort(403);
}
} else {
return $app->redirect($app['url_generator']->generate('page_login'));
}
})->bind('page_documentos')
->secure('ROLE_ADMIN')
You have to use a custom Route class including the SecurityTrait in order to have this method defined.
right man, I haven't read the doc. My mistake, thanks :)
Controller.php line 89
PHP 5.5 Silex 1.2.2
i'm using use Silex\Route\SecurityTrait;
for
$app->get('/', function () use ($app) { return $app['twig']->render('index.html', array()); }) ->secure('ROLE_USER');
and get this error
Method "Silex\Route::secure" does not exist.