<commit_before><?php

namespace BjyAuthorize;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\EventManager\Event;

class Module implements
    AutoloaderProviderInterface,
    BootstrapListenerInterface,
    ConfigProviderInterface,
    ServiceProviderInterface
{
    public function onBootstrap(Event $e)
    {
        $app        = $e->getTarget();
        $sm         = $app->getServiceManager();
        $service    = $sm->get('BjyAuthorize\Service\Authorize');
        $strategy   = $sm->get('BjyAuthorize\View\UnauthorizedStrategy');

        foreach ($service->getGuards() as $guard) {
            $app->getEventManager()->attach('route', array($guard, 'onRoute'), -1000);
        }

        $app->getEventManager()->attach($strategy);
    }

    public function getServiceConfiguration()
    {
        return array(
            'factories' => array(
                'BjyAuthorize\Service\Authorize' => 'BjyAuthorize\Service\AuthorizeFactory',

                'BjyAuthorize\Provider\Identity\ZfcUserZendDb' => function ($sm) {
                    $adapter = $sm->get('zfcuser_zend_db_adapter');
                    $provider = new Provider\Identity\ZfcUserZendDb($adapter);
                    $provider->setUserService($sm->get('zfcuser_user_service'));
                    return $provider;
                },

                'BjyAuthorize\Provider\Identity\ZfcUserDoctrine' => function ($sm) {
                    $em = $sm->get('doctrine.entitymanager.orm_default');
                    $provider = new Provider\Identity\ZfcUserDoctrine($em);
                    $provider->setUserService($sm->get('zfcuser_user_service'));
                    return $provider;
                },

                'BjyAuthorize\View\UnauthorizedStrategy' => function ($sm) {
                    $template = $sm->get('BjyAuthorize\Service\Authorize')->getTemplate();
                    $strategy = new View\UnauthorizedStrategy;
                    $strategy->setTemplate($template);
                    return $strategy;
                },

                'BjyAuthorize\Provider\Role\ZendDb' => function ($sm) {
                    $provider = new Provider\Role\ZendDb;
                    $provider->setAdapter($sm->get('Zend\Db\Adapter\Adapter'));
                    return $provider;
                },

                'BjyAuthorize\Provider\Role\Doctrine' => function ($sm) {
                    $provider = new Provider\Role\Doctrine;
                    return $provider;
                },
            ),
        );
    }

    public function getViewHelperConfiguration()
    {
        return array(
            'factories' => array(
                'isAllowed' => function($sm) {
                    $sm = $sm->getServiceLocator(); // get the main SM instance
                    $helper = new View\Helper\IsAllowed();
                    $helper->setAuthorizeService($sm->get('BjyAuthorize\Service\Authorize'));
                    return $helper;
                }
            ),
        );
    }

    public function getControllerPluginConfiguration()
    {
        return array(
            'factories' => array(
                'isAllowed' => function($sm) {
                    $sm = $sm->getServiceLocator(); // get the main SM instance
                    $helper = new Controller\Plugin\IsAllowed();
                    $helper->setAuthorizeService($sm->get('BjyAuthorize\Service\Authorize'));
                    return $helper;
                }
            ),
        );
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }
}
<commit_msg>update to work with ZF2 master (again)<commit_after><?php

namespace BjyAuthorize;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\EventManager\EventInterface;

class Module implements
    AutoloaderProviderInterface,
    BootstrapListenerInterface,
    ConfigProviderInterface,
    ServiceProviderInterface
{
    public function onBootstrap(EventInterface $e)
    {
        $app        = $e->getTarget();
        $sm         = $app->getServiceManager();
        $service    = $sm->get('BjyAuthorize\Service\Authorize');
        $strategy   = $sm->get('BjyAuthorize\View\UnauthorizedStrategy');

        foreach ($service->getGuards() as $guard) {
            $app->getEventManager()->attach('route', array($guard, 'onRoute'), -1000);
        }

        $app->getEventManager()->attach($strategy);
    }

    public function getServiceConfiguration()
    {
        return array(
            'factories' => array(
                'BjyAuthorize\Service\Authorize' => 'BjyAuthorize\Service\AuthorizeFactory',

                'BjyAuthorize\Provider\Identity\ZfcUserZendDb' => function ($sm) {
                    $adapter = $sm->get('zfcuser_zend_db_adapter');
                    $provider = new Provider\Identity\ZfcUserZendDb($adapter);
                    $provider->setUserService($sm->get('zfcuser_user_service'));
                    return $provider;
                },

                'BjyAuthorize\Provider\Identity\ZfcUserDoctrine' => function ($sm) {
                    $em = $sm->get('doctrine.entitymanager.orm_default');
                    $provider = new Provider\Identity\ZfcUserDoctrine($em);
                    $provider->setUserService($sm->get('zfcuser_user_service'));
                    return $provider;
                },

                'BjyAuthorize\View\UnauthorizedStrategy' => function ($sm) {
                    $template = $sm->get('BjyAuthorize\Service\Authorize')->getTemplate();
                    $strategy = new View\UnauthorizedStrategy;
                    $strategy->setTemplate($template);
                    return $strategy;
                },

                'BjyAuthorize\Provider\Role\ZendDb' => function ($sm) {
                    $provider = new Provider\Role\ZendDb;
                    $provider->setAdapter($sm->get('Zend\Db\Adapter\Adapter'));
                    return $provider;
                },

                'BjyAuthorize\Provider\Role\Doctrine' => function ($sm) {
                    $provider = new Provider\Role\Doctrine;
                    return $provider;
                },
            ),
        );
    }

    public function getViewHelperConfiguration()
    {
        return array(
            'factories' => array(
                'isAllowed' => function($sm) {
                    $sm = $sm->getServiceLocator(); // get the main SM instance
                    $helper = new View\Helper\IsAllowed();
                    $helper->setAuthorizeService($sm->get('BjyAuthorize\Service\Authorize'));
                    return $helper;
                }
            ),
        );
    }

    public function getControllerPluginConfiguration()
    {
        return array(
            'factories' => array(
                'isAllowed' => function($sm) {
                    $sm = $sm->getServiceLocator(); // get the main SM instance
                    $helper = new Controller\Plugin\IsAllowed();
                    $helper->setAuthorizeService($sm->get('BjyAuthorize\Service\Authorize'));
                    return $helper;
                }
            ),
        );
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }
}

{'fraction_non_alphanumeric': 0.11934505761067314, 'fraction_numerical': 0.001091570648878108, 'mean_word_length': 1.7587822014051522, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7334153', 'n_tokens_mistral': 2225, 'n_tokens_neox': 2101, 'n_words': 334}