zf2 - Как переопределить BjyAuthorize\View\RedirectionStrategy

Как я могу переопределить класс RedirectionStrategy в *\vendor\bjyoungblood\bjy-authorize\src\BjyAuthorize\View\RedirectionStrategy.php, чтобы изменить значение атрибута $redirectRoute?

http://pastebin.com/pPKsZcC5

Сначала я следую этому сообщению: Как перенаправить на страницу входа с помощью BjyАвторизовать

Спасибо!!


person Eddz le Bijoutier    schedule 22.08.2013    source источник


Ответы (2)


Я нашел: https://github.com/bjyoungblood/BjyAuthorize/blob/master/docs/unauthorized-strategies.md

    namespace MyApp;

use BjyAuthorize\View\RedirectionStrategy;

class Module
{
    public function onBootstrap(EventInterface $e) {
        $application  = $e->getTarget();
        $eventManager = $application->getEventManager();

        $strategy = new RedirectionStrategy();

        // eventually set the route name (default is ZfcUser's login route)
        $strategy->setRedirectRoute('my/route/name');

        // eventually set the URI to be used for redirects
        $strategy->setRedirectUri('http://example.org/login');

        $eventManager->attach($strategy);
    }
}

Это работает!

person Eddz le Bijoutier    schedule 23.08.2013

добавить в bjyauthorize.global.php

'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy'

а затем в module.php

        use BjyAuthorize\View\RedirectionStrategy;
        $strategy = new RedirectionStrategy(); 
        $strategy->setRedirectRoute('zfcuser/login'); 
        $eventManager->attach($strategy); 
person Saurabh Chandra Patel    schedule 24.05.2015