protected function setValidatorChain(
        SessionManager $sessionManager,
        ServiceLocatorInterface $serviceLocator,
        $sessionConfig
    ) {
        if (!isset($sessionConfig['validators'])
            || !is_array($sessionConfig['validators'])
        ) {
            return;
        }

        $chain = $sessionManager->getValidatorChain();

        foreach ($sessionConfig['validators'] as &$validator) {
            if ($serviceLocator->has($validator)) {
                $validator = $serviceLocator->get($validator);
            } else {
                $validator = new $validator();
            }

            if (!$validator instanceof ValidatorInterface) {
                throw new InvalidArgumentException(
                    'Session Save Handler class must implement '
                    . 'Zend\Session\Validator\ValidatorInterface'
                );
            }

            $chain->attach(
                'session.validate',
                [$validator, 'isValid']
            );
        }
    }
protected function setValidatorChain(
        SessionManager $sessionManager,
        ServiceLocatorInterface $serviceLocator,
        $sessionConfig
    ) {
        if (!isset($sessionConfig['validators'])
            || !is_array($sessionConfig['validators'])
        ) {
            return;
        }

        $chain = $sessionManager->getValidatorChain();

        foreach ($sessionConfig['validators'] as &$validator) {
            if ($serviceLocator->has($validator)) {
                $validator = $serviceLocator->get($validator);
            } else {
                $validator = new $validator();
            }

            if (!$validator instanceof ValidatorInterface) {
                throw new InvalidArgumentException(
                    'Session Save Handler class must implement '
                    . 'Zend\Session\Validator\ValidatorInterface'
                );
            }

            $chain->attach(
                'session.validate',
                [$validator, 'isValid']
            );
        }
    }
protected function setValidatorChain ( SessionManager $ sessionManager , ServiceLocatorInterface $ serviceLocator , $ sessionConfig ) { if ( ! isset ( $ sessionConfig [ 'validators' ] ) || ! is_array ( $ sessionConfig [ 'validators' ] ) ) { return ; } $ chain = $ sessionManager -> getValidatorChain ( ) ; foreach ( $ sessionConfig [ 'validators' ] as & $ validator ) { if ( $ serviceLocator -> has ( $ validator ) ) { $ validator = $ serviceLocator -> get ( $ validator ) ; } else { $ validator = new $ validator ( ) ; } if ( ! $ validator instanceof ValidatorInterface ) { throw new InvalidArgumentException ( 'Session Save Handler class must implement ' . 'Zend\Session\Validator\ValidatorInterface' ) ; } $ chain -> attach ( 'session.validate' , [ $ validator , 'isValid' ] ) ; } }
Attach the Service Validators to the Session

@param SessionManager          $sessionManager Zend Session Manager
@param ServiceLocatorInterface $serviceLocator Zend Service Locator
@param array                   $sessionConfig  Session Config Array

@return void
@throws InvalidArgumentException
Attach the Service Validators to the Session