<commit_before><?php
namespace Xi\Zend\Application\Resource;

use Doctrine\Common\ClassLoader as DoctrineClassLoader;

/**
 * Adds a DoctrineClassLoader to the autoloader used for each enabled module.
 */
class Moduleautoloaders extends AbstractResource
{
    public function init()
    {
        $this->getBootstrap()->bootstrap('FrontController');
        $autoloader = $this->getAutoloader();
        foreach ($this->getModuleRoots() as $moduleName => $moduleRoot) {
            $autoloader->pushAutoloader($this->getNamespaceAutoloader($moduleName, $moduleRoot), "$moduleName\\");
        }
    }
    
    /**
     * @param string $namespace
     * @param string $root path
     * @return callback
     */
    protected function getNamespaceAutoloader($namespace, $root)
    {
        return array(new DoctrineClassLoader($namespace, $root), 'loadClass');
    }
    
    /**
     * @return \Zend_Controller_Front
     */
    private function getFrontController()
    {
        return $this->getBootstrap()->getResource('FrontController');
    }
    
    /**
     * @return array<ModuleName => root>
     */
    private function getModuleRoots()
    {
        $result = array();
        foreach ($this->getFrontController()->getControllerDirectory() as $controllerDirectory) {
            $moduleDirectory = dirname($controllerDirectory);
            $moduleName = basename($moduleDirectory);
            $moduleRoot = dirname($moduleDirectory);
            $result[$moduleName] = $moduleRoot;
        }
        return $result;
    }
}<commit_msg>Added autoloaders for library/ and application/library<commit_after><?php
namespace Xi\Zend\Application\Resource;

use \Xi\Zend\Application\ClassLoader;

/**
 * Adds a \Xi\Zend\Application\ClassLoader to the autoloader used for each enabled module.
 */
class Moduleautoloaders extends AbstractResource
{
    public function init()
    {
        $this->getBootstrap()->bootstrap('FrontController');
        $autoloader = $this->getAutoloader();
        $autoloader->pushAutoloader($this->getLibraryAutoloader());
        $autoloader->pushAutoloader($this->getApplicationLibraryAutoloader());
        foreach ($this->getModuleRoots() as $moduleName => $moduleRoot) {
            $autoloader->pushAutoloader($this->getNamespaceAutoloader($moduleName, $moduleRoot), "$moduleName\\");
        }
    }
    
    /**
     * @return callback
     */
    protected function getLibraryAutoloader()
    {
        return array(new ClassLoader(null, realpath(APPLICATION_PATH . '/../library')), 'loadClass');
    }
    
    /**
     * @return callback
     */
    protected function getApplicationLibraryAutoloader()
    {
        return array(new ClassLoader(null, APPLICATION_PATH . '/library'), 'loadClass');
    }
    
    /**
     * @param string $namespace
     * @param string $root path
     * @return callback
     */
    protected function getNamespaceAutoloader($namespace, $root)
    {
        return array(new ClassLoader($namespace, $root), 'loadClass');
    }
    
    /**
     * @return \Zend_Controller_Front
     */
    protected function getFrontController()
    {
        return $this->getBootstrap()->getResource('FrontController');
    }
    
    /**
     * @return array<ModuleName => root>
     */
    protected function getModuleRoots()
    {
        $result = array();
        foreach ($this->getFrontController()->getControllerDirectory() as $controllerDirectory) {
            $moduleDirectory = dirname($controllerDirectory);
            $moduleName = basename($moduleDirectory);
            $moduleRoot = dirname($moduleDirectory);
            $result[$moduleName] = $moduleRoot;
        }
        return $result;
    }
}
{'fraction_non_alphanumeric': 0.1277461350691619, 'fraction_numerical': 0.0, 'mean_word_length': 2.8217616580310882, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '6644715', 'n_tokens_mistral': 1023, 'n_tokens_neox': 1017, 'n_words': 193}