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']
            );
        }
    }