sábado, 30 de janeiro de 2016

Strict (2048): Declaration of App\Controller\UsersController::beforeFilter() should be compatible with App\Controller\AppController::beforeFilter(Cake\Event\Event $event) [APP/Controller\UsersController.php, line 12]

Strict (2048): Declaration of App\Controller\UsersController::beforeFilter() should be compatible with App\Controller\AppController::beforeFilter(Cake\Event\Event $event) [APP/Controller\UsersController.php, line 12]
Warning (4096): Argument 1 passed to App\Controller\UsersController::beforeFilter() must be an instance of App\Controller\Event, instance of Cake\Event\Event given, called in C:\Users\daniel\blog\vendor\cakephp\cakephp\src\Event\EventManager.php on line 385 and defined [APP/Controller\UsersController.php, line 14]

Hi!

If you are just like me studying the tutorial

CakePHP Cookbook Documentation
Release 3.x
Cake Software Foundation
January 18, 2016

You should have been found this problem when you finished the blog example.

Solution


Change this

    public function beforeFilter(Event $event)
    {
        parent::beforeFilter($event);
        // Allow users to register and logout.
        // You should not add the "login" action to allow list. Doing so would
        // cause problems with normal functioning of AuthComponent.
        $this->Auth->allow(['add', 'logout']);
    }

For this

    public function beforeFilter(\Cake\Event\Event $event)
    {
        $this->Auth->allow(['add','logout']);
    }
 
Good luck!




Nenhum comentário:

Postar um comentário