Как задать имена для контейнеров сеансов Zend в приложении ZF3? - PullRequest
0 голосов
/ 27 февраля 2020

Когда я отлаживаю свое приложение и анализирую $_SESSION, я вижу три элемента уровня root: __ZF, Zend_Validator_Csrf_salt_csrf и myapp_auth. Последний устанавливается явно. Я делаю это имя контейнера доступным в конфигах

    ...
    'session_containers' => [
        'myapp_common',
        'myapp_auth',
    ],
    ...

и создаю SessionStorage с ним:

namespace Authentication\Service\Factory;

use Authentication\Service\AuthenticationService;
use Interop\Container\ContainerInterface;
use Zend\Authentication\Storage\Session as SessionStorage;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\Session\SessionManager;

class AuthenticationServiceFactory implements FactoryInterface
{
    /**
     * @inheritDoc
     */
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $sessionManager = $container->get(SessionManager::class);
        $authenticationStorage = new SessionStorage('myapp_auth', 'session', $sessionManager);
        $authenticationAdapter = $container->get('AuthenticationAdapter');
        return new AuthenticationService($authenticationStorage, $authenticationAdapter);
    }
}

Возможно ли это / Как манипулировать именами по умолчанию Сеансовые контейнеры ZF __ZF и Zend_Validator_Csrf_salt_csrf?

...