<commit_before><?php
Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
Zend_Controller_Action_HelperBroker::addHelper(new Kwf_Controller_Action_Helper_ViewRenderer());

class Kwf_Controller_Front extends Zend_Controller_Front
{
    private $_webRouter;

    protected function _init()
    {
        $this->setDispatcher(new Kwf_Controller_Dispatcher());

        $this->setControllerDirectory('controllers');
        $this->returnResponse(true);
        $this->setParam('disableOutputBuffering', true);

        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Welcome',
                                        'kwf_controller_action_welcome');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/User',
                                        'kwf_controller_action_user');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Error',
                                        'kwf_controller_action_error');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Pool',
                                'kwf_controller_action_pool');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Debug',
                                'kwf_controller_action_debug');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Cli',
                                'kwf_controller_action_cli');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Cli/Web',
                                'kwf_controller_action_cli_web');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Media',
                                'kwf_controller_action_media');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Spam',
                                        'kwf_controller_action_spam');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Enquiries',
                                        'kwf_controller_action_enquiries');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Redirects',
                                        'kwf_controller_action_redirects');
        $this->addControllerDirectory(KWF_PATH . '/tests', 'kwf_test');
        $this->addControllerDirectory('tests', 'web_test');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Trl',
                                'kwf_controller_action_trl');
        if (file_exists('controllers/Cli')) {
            $this->addControllerDirectory('controllers/Cli', 'cli');
        }
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Component',
                                        'kwf_controller_action_component');

        $iterator = new DirectoryIterator('controllers');
        $filter = new Zend_Filter_Word_CamelCaseToDash();
        foreach($iterator as $fileinfo) {
            if (!$fileinfo->isDot() && $fileinfo->isDir() && $fileinfo->getBasename() != 'Cli') {
                $this->addControllerDirectory($fileinfo->getPathname(), strtolower($filter->filter($fileinfo->getBasename())));
            }
        }


        $plugin = new Zend_Controller_Plugin_ErrorHandler();
        $plugin->setErrorHandlerModule('kwf_controller_action_error');
        if (php_sapi_name() == 'cli') {
            $plugin->setErrorHandlerController('cli');
        }
        $this->registerPlugin($plugin);
    }

    public static function getInstance()
    {
        if (null === self::$_instance) {
            $class = Kwf_Config::getValue('frontControllerClass');<commit_msg>only add controllers if controllers directory exists, fixes kwf tests<commit_after><?php
Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
Zend_Controller_Action_HelperBroker::addHelper(new Kwf_Controller_Action_Helper_ViewRenderer());

class Kwf_Controller_Front extends Zend_Controller_Front
{
    private $_webRouter;

    protected function _init()
    {
        $this->setDispatcher(new Kwf_Controller_Dispatcher());

        $this->setControllerDirectory('controllers');
        $this->returnResponse(true);
        $this->setParam('disableOutputBuffering', true);

        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Welcome',
                                        'kwf_controller_action_welcome');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/User',
                                        'kwf_controller_action_user');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Error',
                                        'kwf_controller_action_error');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Pool',
                                'kwf_controller_action_pool');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Debug',
                                'kwf_controller_action_debug');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Cli',
                                'kwf_controller_action_cli');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Cli/Web',
                                'kwf_controller_action_cli_web');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Media',
                                'kwf_controller_action_media');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Spam',
                                        'kwf_controller_action_spam');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Enquiries',
                                        'kwf_controller_action_enquiries');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Redirects',
                                        'kwf_controller_action_redirects');
        $this->addControllerDirectory(KWF_PATH . '/tests', 'kwf_test');
        $this->addControllerDirectory('tests', 'web_test');
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Trl',
                                'kwf_controller_action_trl');
        if (file_exists('controllers/Cli')) {
            $this->addControllerDirectory('controllers/Cli', 'cli');
        }
        $this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Component',
                                        'kwf_controller_action_component');

        if (is_dir('controllers')) {
            //automatically add controller directories from web based on existing directories in filesystem in web
            $iterator = new DirectoryIterator('controllers');
            $filter = new Zend_Filter_Word_CamelCaseToDash();
            foreach($iterator as $fileinfo) {
                if (!$fileinfo->isDot() && $fileinfo->isDir() && $fileinfo->getBasename() != 'Cli') {
                    $this->addControllerDirectory($fileinfo->getPathname(), strtolower($filter->filter($fileinfo->getBasename())));
                }
            }
        }


        $plugin = new Zend_Controller_Plugin_ErrorHandler();
        $plugin->setErrorHandlerModule('kwf_controller_action_error');
        if (php_sapi_name() == 'cli') {
            $plugin->setErrorHandlerController('cli');
        }
        $this->registerPlugin($plugin);
    }

    public static function getInstance()
    {
        if (null === self::$_instance) {
            $class = Kwf_Config::getValue('frontControllerClass');
{'fraction_non_alphanumeric': 0.11972588013974737, 'fraction_numerical': 0.0, 'mean_word_length': 2.361788617886179, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3591299', 'n_tokens_mistral': 1989, 'n_tokens_neox': 1898, 'n_words': 226}