<commit_before><?php
namespace Zf2SimpleAcl;

use Zf2SimpleAcl\Authentication\AuthenticationService;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\Mvc\MvcEvent;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zf2SimpleAcl\Authentication\AuthenticationAggregator;
use Zf2SimpleAcl\Authentication\Recognizer\CronRecognizerService;
use Zf2SimpleAcl\Exception\RuntimeException;
use Zf2SimpleAcl\Guard\RouteGuard;
use Zf2SimpleAcl\Options\ModuleOptions;
use Zf2SimpleAcl\View\Strategy\ForbiddenStrategy;
use Zf2SimpleAcl\View\Strategy\RedirectionStrategy;

class Module implements AutoloaderProviderInterface, ConfigProviderInterface, ServiceProviderInterface
{
    public function onBootstrap(MvcEvent $e)
    {
        /* @var $sm \Zend\ServiceManager\ServiceManager */
        $sm = $e->getApplication()->getServiceManager();

        $userEntityClass = $sm->get('zfcuser_module_options')->getUserEntityClass();
        $classRef = new \ReflectionClass($userEntityClass);

        if (!$classRef->implementsInterface('Zf2SimpleAcl\Entity\UserInterface')) {
            throw new \InvalidArgumentException($userEntityClass.
            ' must implement Zf2SimpleAcl\Entity\UserInterface');
        }

        $eventManager = $e->getApplication()->getEventManager();


        $recognizers = $sm->get('zf2simpleacl_module_options')->getRecognizers();

        $authService = $sm->get('zfcuserauthservice');
        if (!empty($recognizers) && count($recognizers)) {
            $authService = new AuthenticationAggregator();
            $authService->addService(new AuthenticationService($sm->get('zfcuserauthservice')));

            foreach ($recognizers as $recognizer) {
                if (!($sm->has($recognizer))) {
                    if (!($sm->has('zf2simpleacl_recognizer_'.$recognizer))) {
                        throw new RuntimeException("Could not find recognizer service with name
                                                    [$recognizer] nor with [zf2simpleacl_recognizer_$recognizer]");
                    } else {
                        $recognizer = 'zf2simpleacl_recognizer_'.$recognizer;
                    }
                }
                $authService->addService($sm->get($recognizer));
            }
        }
        $eventManager->attach(new RouteGuard($sm->get('zf2simpleacl_acl'),
                                             $authService));

        $eventManager->attach(new RedirectionStrategy($sm->get('zf2simpleacl_module_options')));
        $eventManager->attach(new ForbiddenStrategy());
    }

    public function getConfig()
    {
        return array(
            'view_manager' => array(
                'template_map' => array(
                    'error/403'               => __DIR__ . '/view/error/403.phtml'
                )
            )
        );
    }

    public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',<commit_msg>Fixed little mistake, with wrapping standard Auth service.<commit_after><?php
namespace Zf2SimpleAcl;

use Zf2SimpleAcl\Authentication\AuthenticationService;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\Mvc\MvcEvent;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zf2SimpleAcl\Authentication\AuthenticationAggregator;
use Zf2SimpleAcl\Authentication\Recognizer\CronRecognizerService;
use Zf2SimpleAcl\Exception\RuntimeException;
use Zf2SimpleAcl\Guard\RouteGuard;
use Zf2SimpleAcl\Options\ModuleOptions;
use Zf2SimpleAcl\View\Strategy\ForbiddenStrategy;
use Zf2SimpleAcl\View\Strategy\RedirectionStrategy;

class Module implements AutoloaderProviderInterface, ConfigProviderInterface, ServiceProviderInterface
{
    public function onBootstrap(MvcEvent $e)
    {
        /* @var $sm \Zend\ServiceManager\ServiceManager */
        $sm = $e->getApplication()->getServiceManager();

        $userEntityClass = $sm->get('zfcuser_module_options')->getUserEntityClass();
        $classRef = new \ReflectionClass($userEntityClass);

        if (!$classRef->implementsInterface('Zf2SimpleAcl\Entity\UserInterface')) {
            throw new \InvalidArgumentException($userEntityClass.
            ' must implement Zf2SimpleAcl\Entity\UserInterface');
        }

        $eventManager = $e->getApplication()->getEventManager();


        $recognizers = $sm->get('zf2simpleacl_module_options')->getRecognizers();

        $authService = new AuthenticationService($sm->get('zfcuserauthservice'));

        if (!empty($recognizers) && count($recognizers)) {
            $authService = new AuthenticationAggregator();
            $authService->addService(new AuthenticationService($sm->get('zfcuserauthservice')));

            foreach ($recognizers as $recognizer) {
                if (!($sm->has($recognizer))) {
                    if (!($sm->has('zf2simpleacl_recognizer_'.$recognizer))) {
                        throw new RuntimeException("Could not find recognizer service with name
                                                    [$recognizer] nor with [zf2simpleacl_recognizer_$recognizer]");
                    } else {
                        $recognizer = 'zf2simpleacl_recognizer_'.$recognizer;
                    }
                }
                $authService->addService($sm->get($recognizer));
            }
        }

        $eventManager->attach(new RouteGuard($sm->get('zf2simpleacl_acl'),
                                             $authService));

        $eventManager->attach(new RedirectionStrategy($sm->get('zf2simpleacl_module_options')));
        $eventManager->attach(new ForbiddenStrategy());
    }

    public function getConfig()
    {
        return array(
            'view_manager' => array(
                'template_map' => array(
                    'error/403'               => __DIR__ . '/view/error/403.phtml'
                )
            )
        );
    }

    public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
{'fraction_non_alphanumeric': 0.11160714285714286, 'fraction_numerical': 0.007971938775510204, 'mean_word_length': 2.63441483198146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4276339', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1642, 'n_words': 251}