Esempio n. 1
0
 public function run()
 {
     $di = new \Phalcon\DI\FactoryDefault();
     // Config
     require_once APPLICATION_PATH . '/modules/Cms/Config.php';
     $config = \Cms\Config::get();
     $di->set('config', $config);
     // Registry
     $registry = new \Phalcon\Registry();
     $di->set('registry', $registry);
     // Loader
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces($config->loader->namespaces->toArray());
     $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
     $loader->register();
     require_once APPLICATION_PATH . '/../vendor/autoload.php';
     // Database
     $db = new \Phalcon\Db\Adapter\Pdo\Mysql(["host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname, "charset" => $config->database->charset]);
     $di->set('db', $db);
     // View
     $this->initView($di);
     // URL
     $url = new \Phalcon\Mvc\Url();
     $url->setBasePath($config->base_path);
     $url->setBaseUri($config->base_path);
     $di->set('url', $url);
     // Cache
     $this->initCache($di);
     // CMS
     $cmsModel = new \Cms\Model\Configuration();
     $registry->cms = $cmsModel->getConfig();
     // Отправляем в Registry
     // Application
     $application = new \Phalcon\Mvc\Application();
     $application->registerModules($config->modules->toArray());
     // Events Manager, Dispatcher
     $this->initEventManager($di);
     // Session
     $session = new \Phalcon\Session\Adapter\Files();
     $session->start();
     $di->set('session', $session);
     $acl = new \Application\Acl\DefaultAcl();
     $di->set('acl', $acl);
     // JS Assets
     $this->initAssetsManager($di);
     // Flash helper
     $flash = new \Phalcon\Flash\Session(['error' => 'ui red inverted segment', 'success' => 'ui green inverted segment', 'notice' => 'ui blue inverted segment', 'warning' => 'ui orange inverted segment']);
     $di->set('flash', $flash);
     $di->set('helper', new \Application\Mvc\Helper());
     // Routing
     $this->initRouting($application, $di);
     $application->setDI($di);
     // Main dispatching process
     $this->dispatch($di);
 }
Esempio n. 2
0
 public static function run()
 {
     global $di;
     $di = new \Phalcon\DI\FactoryDefault();
     self::initSystemConst();
     self::initSystemService();
     self::initAutoloaders();
     $application = new \Phalcon\Mvc\Application($di);
     //Register the installed modules
     $application->registerModules(array('home' => array('className' => 'Application\\Home\\Module', 'path' => '../application/modules/home/module.php'), 'admin' => array('className' => 'Application\\Admin\\Module', 'path' => '../application/modules/admin/module.php'), 'api' => array('className' => 'Application\\Api\\Module', 'path' => '../application/modules/Api/module.php')));
     echo $application->handle()->getContent();
 }
Esempio n. 3
0
    });
    /** Start the session the first time some component request the session service */
    $di->set('session', function () {
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        return $session;
    });
    $di->set('cookies', function () {
        $cookies = new \Phalcon\Http\Response\Cookies();
        $cookies->useEncryption(false);
        return $cookies;
    });
    /** Handle the request */
    $application = new \Phalcon\Mvc\Application();
    $application->setDI($di);
    /** Register application modules */
    $application->registerModules(array('users' => array('className' => 'Modules\\Users\\Module', 'path' => '../apps/users/Module.php'), 'admin' => array('className' => 'Modules\\Admin\\Module', 'path' => '../apps/admin/Module.php')));
    function sanitize_output($buffer)
    {
        $search = array('/\\>[^\\S ]+/s', '/[^\\S ]+\\</s', '/(\\s)+/s');
        $replace = array('>', '<', '\\1');
        $buffer = preg_replace($search, $replace, $buffer);
        return $buffer;
    }
    ob_start("sanitize_output");
    echo $application->handle()->getContent();
} catch (Phalcon\Exception $e) {
    echo $e->getMessage();
} catch (PDOException $e) {
    echo $e->getMessage();
}
Esempio n. 4
0
        foreach ($routers as $name => $rule) {
            $pattern = $rule->pattern;
            unset($rule->pattern);
            $router->add($pattern, $rule->toArray())->setName($name);
        }
    }
    return $router;
});
$di->setShared('db', function () use($config) {
    $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name, "charset" => $config->database->charset, "collation" => $config->database->collation));
    return $connection;
});
$di->set('modelsManager', new \Phalcon\Mvc\Model\Manager());
$di->setShared('url', function () use($config) {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri($config->app->base);
    return $url;
});
try {
    $application = new Phalcon\Mvc\Application();
    $application->setDI($di);
    if (!empty($config->apps)) {
        foreach ($config->apps as $name => $app) {
            $apps[$name] = array('className' => $app . '\\Module', 'path' => '../' . $config->app->apps . $name . DIRECTORY_SEPARATOR . 'Module.php');
        }
    }
    $application->registerModules($apps);
    echo $application->handle()->getContent();
} catch (Exception $e) {
    echo $e->getMessage();
}
Esempio n. 5
0
    $router->add("/dashboard", array('module' => 'dashboard', 'controller' => 'index', 'action' => 'index'));
    $router->add("/login", array('module' => 'dashboard', 'controller' => 'login', 'action' => 'index'));
    $router->add("/logout", array('module' => 'dashboard', 'controller' => 'login', 'action' => 'logout'));
    $router->add('/dashboard/([a-zA-Z\\-]+)/([a-zA-Z\\-]+)', array('module' => 'dashboard', 'controller' => 1, 'action' => 2))->setName("controllers")->convert('action', function ($action) {
        return \Phalcon\Text::lower(\Phalcon\Text::camelize($action));
    });
    $router->removeExtraSlashes(true);
    return $router;
});
/**
 * Start the session the first time some component request the session service
 */
$di->set('dispatcher', function () use($di) {
    $dispatcher = new \Phalcon\Mvc\Dispatcher();
    $eventsManager = $di->getShared('eventsManager');
    $security = new Security($di);
    $eventsManager->attach('dispatch', $security);
    $dispatcher->setEventsManager($eventsManager);
    return $dispatcher;
});
$di->set('session', function () {
    $session = new Phalcon\Session\Adapter\Files();
    $session->start();
    return $session;
});
$application = new \Phalcon\Mvc\Application();
//Pass the DI to the application
$application->setDI($di);
//Register the installed modules
$application->registerModules(array('frontend' => array('className' => 'Modules\\Frontend\\Module', 'path' => '../apps/modules/frontend/Module.php'), 'dashboard' => array('className' => 'Modules\\Dashboard\\Module', 'path' => '../apps/modules/dashboard/Module.php')));
echo $application->handle()->getContent();
Esempio n. 6
0
    /**
     * The URL component is used to generate all kind of urls in the application
     */
    $di->set('url', function () {
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/@@name@@/');
        return $url;
    });
    /**
     * Start the session the first time some component request the session service
     */
    $di->set('session', function () {
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        return $session;
    });
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application();
    $application->setDI($di);
    /**
     * Register application modules
     */
    $application->registerModules(array('frontend' => array('className' => '@@namespace@@\\Frontend\\Module', 'path' => '../apps/frontend/Module.php')));
    echo $application->handle()->getContent();
} catch (Phalcon\Exception $e) {
    echo $e->getMessage();
} catch (PDOException $e) {
    echo $e->getMessage();
}
Esempio n. 7
0
  */
 $config = (include __DIR__ . "/../app/config/config.php");
 /**
  * Read auto-loader
  */
 include $config->application->appDir . "config/loader.php";
 /**
  * Read services
  */
 include $config->application->appDir . "config/services.php";
 /**
  * Handle the request
  */
 $application = new \Phalcon\Mvc\Application($di);
 // print_r($config->modules->toArray());exit();
 $application->registerModules($config->modules->toArray());
 if (substr($di['request']->getUserAgent(), 0, 11) === 'PHP Yar Rpc') {
     $service = new Yar_Server(new \App\Bootstrap\Service($application));
     $service->handle();
 } else {
     if ($di['request']->getQuery('_method') == 'yar') {
         list($tmp, $module, $controller, $action) = explode('/', $di['request']->getURI());
         $className = "App\\Modules\\" . ucfirst($module) . "\\Controllers\\" . ucfirst($controller) . "Controller";
         include "../app/modules/user/controllers/IndexController.php";
         // $obj = "App\Modules\User\Controllers\IndexController()";
         $service = new Yar_Server();
         $service->handle();
     } else {
         $application->getDI()->set('params', function () use($di) {
             return $di['request']->get();
         });
Esempio n. 8
0
<?php

use IGO\Modules;
error_reporting(E_ALL);
try {
    $config = (include __DIR__ . "/../app/config/config.php");
    include __DIR__ . "/../app/config/loader.php";
    include __DIR__ . "/../app/config/services.php";
    $application = new \Phalcon\Mvc\Application($di);
    $application->registerModules($di->get('chargeurModules')->obtenirDefinitionModules());
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Esempio n. 9
0
            $compiler->addFilter('truncate', function ($resolvedArgs, $exprArgs) {
                $string = $exprArgs[0]['expr']['value'];
                $length = (int) $exprArgs[1]['expr']['value'];
                $end = isset($exprArgs[2]) ? $exprArgs[2]['expr']['value'] : '...';
                return "mb_strimwidth({$string}, 0, {$length}, '{$end}', 'UTF-8')";
            });
            $compiler->addFilter('shift', function ($resolvedArgs, $exprArgs) {
                return "array_shift({$resolvedArgs})";
            });
            $compiler->addFilter('number_format', function ($resolvedArgs, $exprArgs) {
                return "number_format({$resolvedArgs})";
            });
            return $volt;
        }));
        // $view->setVar('FACEBOOK_ADMIN_ID', $config->facebook[ENVIRONMENT]->admin);
        // $view->setVar('GOOGLE_ANALYTICS_KEY', $config->ga[ENVIRONMENT]->key);
        return $view;
    }, true);
    $eventsManager = new \Phalcon\Events\Manager();
    $eventsManager->attach("application:afterHandleRequest", function ($event, $application) {
        $datetime = gmdate("D, d M Y H:i:s") . ' GMT';
        $application->response->setHeader('Last-Modified', $datetime);
        return true;
    });
    $application = new \Phalcon\Mvc\Application($di);
    $application->setEventsManager($eventsManager);
    $application->registerModules(array(SITENAME => array('className' => 'Lininliao\\' . SITENAME . '\\Module', 'path' => ROOT . DS . 'apps' . DS . SITENAME . DS . 'Module.php')));
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Esempio n. 10
0
 public static function run()
 {
     if (in_array(APPLICATION_ENV, array('development'))) {
         $debug = new \Phalcon\Debug();
         $debug->listen();
     }
     $di = new \Phalcon\DI\FactoryDefault();
     $config = (include APPLICATION_PATH . '/config/application.php');
     $di->set('config', $config);
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces($config->loader->namespaces->toArray());
     $loader->register();
     $loader->registerDirs(array(APPLICATION_PATH . "/plugins/"));
     $db = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname, "charset" => $config->database->charset));
     $di->set('db', $db);
     $view = new View();
     /* $view->disableLevel(array(
        View::LEVEL_BEFORE_TEMPLATE => true,
        View::LEVEL_LAYOUT          => true,
        View::LEVEL_AFTER_TEMPLATE  => true
        )); */
     define('MAIN_VIEW_PATH', '../../../views/');
     $view->setMainView(MAIN_VIEW_PATH . 'main');
     $view->setLayoutsDir(MAIN_VIEW_PATH . '/layouts/');
     $view->setPartialsDir(MAIN_VIEW_PATH . '/partials/');
     $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
     $volt->setOptions(array('compiledPath' => APPLICATION_PATH . '/cache/volt/'));
     $volt->initCompiler();
     $viewEngines = array(".volt" => $volt);
     $view->registerEngines($viewEngines);
     $di->set('view', $view);
     $viewSimple = new \Phalcon\Mvc\View\Simple();
     $viewSimple->registerEngines($viewEngines);
     $di->set('viewSimple', $viewSimple);
     $url = new \Phalcon\Mvc\Url();
     $url->setBasePath('/');
     $url->setBaseUri('/');
     $application = new \Phalcon\Mvc\Application();
     $application->registerModules($config->modules->toArray());
     $router = new \Application\Mvc\Router\DefaultRouter();
     foreach ($application->getModules() as $module) {
         $className = str_replace('Module', 'Routes', $module['className']);
         if (class_exists($className)) {
             $class = new $className();
             $router = $class->init($router);
         }
     }
     $di->set('router', $router);
     $eventsManager = new \Phalcon\Events\Manager();
     $dispatcher = new \Phalcon\Mvc\Dispatcher();
     $eventsManager->attach("dispatch:beforeException", function ($event, $dispatcher, $exception) {
         new ExceptionPlugin($dispatcher, $exception);
     });
     $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) {
         new LocalizationPlugin($dispatcher);
     });
     $eventsManager->attach("acl", function ($event, $acl) {
         if ($event->getType() == 'beforeCheckAccess') {
             echo $acl->getActiveRole(), $acl->getActiveResource(), $acl->getActiveAccess();
         }
     });
     $dispatcher->setEventsManager($eventsManager);
     $di->set('dispatcher', $dispatcher);
     $session = new \Phalcon\Session\Adapter\Files();
     $session->start();
     $di->set('session', $session);
     $acl = new \Application\Acl\DefaultAcl();
     $acl->setEventsManager($eventsManager);
     $di->set('acl', $acl);
     $assets = new \Phalcon\Assets\Manager();
     $di->set('assets', $assets);
     $flash = new \Phalcon\Flash\Session(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'));
     $di->set('flash', $flash);
     $di->set('helper', new \Application\Mvc\Helper());
     $application->setDI($di);
     echo $application->handle()->getContent();
 }
Esempio n. 11
0
<?php

iconv_set_encoding('internal_encoding', 'UTF-8');
setlocale(LC_ALL, 'ru_RU.UTF-8');
define('PUBLICROOT', __DIR__);
define('COREROOT', dirname(__DIR__));
(new \Phalcon\Debug())->listen(true, true);
/**
 * Read the configuration
 */
$config = (include __DIR__ . "/../app/config/config.php");
/**
 * Read auto-loader
 */
include __DIR__ . "/../app/config/loader.php";
/**
 * Read services
 */
include __DIR__ . "/../app/config/services.php";
/**
 * Handle the request
 */
$application = new \Phalcon\Mvc\Application($di);
$application->registerModules(require __DIR__ . '/../app/config/modules.php');
echo $application->handle()->getContent();
Esempio n. 12
0
<?php

$di = new \Phalcon\DI\FactoryDefault();
$di->set('router', function () {
    $router = new \Phalcon\Mvc\Router();
    $router->setDefaultModule('shop');
    $router->add('/:module/:controller/:action/:params', array('module' => 1, 'controller' => 2, 'action' => 3, 'params' => 4));
    return $router;
});
try {
    $application = new \Phalcon\Mvc\Application($di);
    $application->registerModules(array('shop' => array('className' => 'Bishop\\Shop\\Module', 'path' => ROOT_DIR . '/app/shop/Module.php'), 'backend' => array('className' => 'Bishop\\Admin\\Module', 'path' => ROOT_DIR . '/app/admin/Module.php')));
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
<?php

try {
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    define('PUBLIC_PATH', realpath(dirname(__FILE__)));
    /**
     * Read the configuration
     */
    $config = (include __DIR__ . "/../app/config/config.php");
    /**
     * Read auto-loader
     */
    include __DIR__ . "/../app/config/loader.php";
    //include __DIR__ . "/../vendor/autoload.php";
    require_once __DIR__ . "/../app/config/define.php";
    /**
     * Read services
     */
    include __DIR__ . "/../app/config/services.php";
    include __DIR__ . "/../app/config/debug.php";
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application($di);
    $application->registerModules(array('frontend' => array('className' => 'Multiple\\Frontend\\Module', 'path' => '../app/frontend/Module.php'), 'methodist' => array('className' => 'Multiple\\Methodist\\Module', 'path' => '../app/methodist/Module.php'), 'student' => array('className' => 'Multiple\\Student\\Module', 'path' => '../app/student/Module.php'), 'crud' => array('className' => 'Multiple\\Crud\\Module', 'path' => '../app/crud/Module.php'), 'rest' => array('className' => 'Multiple\\Rest\\Module', 'path' => '../app/rest/Module.php')));
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Esempio n. 14
0
        echo '<script type="text/javascript">' . $console . '</script>';
    }
    require_once __DIR__ . '/../app/library/PhpConsole/__autoload.php';
    $handler = PhpConsole\Handler::getInstance();
    $handler->start();
    define('INDEX_PATH', __DIR__);
    /**
     * Read the configuration
     */
    $config = (include __DIR__ . "/../app/config/config.php");
    /**
     * Read auto-loader
     */
    include __DIR__ . "/../app/config/loader.php";
    /**
     * Read services
     */
    include __DIR__ . "/../app/config/services.php";
    /**
     * Read Common Method
     */
    include $config->application->controllersDir . 'CommonController.php';
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application($di);
    $application->registerModules($di->getRegisterModules());
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Esempio n. 15
0
        break;
    default:
        error_log('Error: The application ENV constant is not set correctly.');
        exit(1);
}
// Create the dependency injector for the Phalcon framework
$di = new Phalcon\DI\FactoryDefault();
$di->setShared('config', function () {
    $config = (require __DIR__ . "/config/config.php");
    return $config;
});
$config = $di->get('config');
if (!file_exists($config->path->tmpDir)) {
    mkdir($config->path->tmpDir);
}
// Setup composer autoloading so that it doesn't need to be specified in each Module
require_once $config->path->composerDir . 'autoload.php';
require $config->path->configDir . 'services.php';
require $config->path->configDir . 'services_web.php';
if (DEV) {
    class_alias('\\Webird\\Debug', '\\Dbg', true);
}
// Handle the request and inject DI
$application = new \Phalcon\Mvc\Application($di);
$application->registerModules(['web' => ['className' => 'Webird\\Web\\Module'], 'admin' => ['className' => 'Webird\\Admin\\Module'], 'api' => ['className' => 'Webird\\Api\\Module']]);
try {
    echo $application->handle()->getContent();
} catch (\Exception $e) {
    error_log('Exception: ' . $e->getMessage());
    exit(1);
}
Esempio n. 16
0
 public function testApplicationModulesDefinitionClosure()
 {
     // Creates the autoloader
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces(array('Frontend\\Controllers' => __DIR__ . '/modules/frontend/controllers/', 'Backend\\Controllers' => __DIR__ . '/modules/backend/controllers/'));
     $loader->register();
     $_GET['_url'] = '/login';
     Phalcon\DI::reset();
     $di = new Phalcon\DI\FactoryDefault();
     $di->set('router', function () {
         $router = new Phalcon\Mvc\Router(false);
         $router->add('/index', array('controller' => 'index', 'module' => 'frontend', 'namespace' => 'Frontend\\Controllers\\'));
         $router->add('/login', array('controller' => 'login', 'module' => 'backend', 'namespace' => 'Backend\\Controllers\\'));
         return $router;
     });
     $application = new Phalcon\Mvc\Application();
     $view = new \Phalcon\Mvc\View();
     $application->registerModules(array('frontend' => function ($di) use($view) {
         $di->set('view', function () use($view) {
             $view = new \Phalcon\Mvc\View();
             $view->setViewsDir(__DIR__ . '/modules/frontend/views/');
             return $view;
         });
     }, 'backend' => function ($di) use($view) {
         $di->set('view', function () use($view) {
             $view->setViewsDir(__DIR__ . '/modules/backend/views/');
             return $view;
         });
     }));
     $application->setDi($di);
     $this->assertEquals($application->handle()->getContent(), '<html>here</html>' . PHP_EOL);
     $loader->unregister();
 }
Esempio n. 17
0
    /**
     * The URL component is used to generate all kind of urls in the application
     */
    $di->set('url', function () {
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/mvc/multiple-shared-layouts/');
        return $url;
    });
    /**
     * Start the session the first time some component request the session service
     */
    $di->set('session', function () {
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        return $session;
    });
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application();
    $application->setDI($di);
    /**
     * Register application modules
     */
    $application->registerModules(array('frontend' => array('className' => 'Modules\\Frontend\\Module', 'path' => '../apps/frontend/Module.php'), 'backend' => array('className' => 'Modules\\Backend\\Module', 'path' => '../apps/backend/Module.php')));
    echo $application->handle()->getContent();
} catch (Phalcon\Exception $e) {
    echo $e->getMessage();
} catch (PDOException $e) {
    echo $e->getMessage();
}
Esempio n. 18
0
 public function run()
 {
     $di = new \Phalcon\DI\FactoryDefault();
     $config = (include APPLICATION_PATH . '/config/application.php');
     $di->set('config', $config);
     $registry = new \Phalcon\Registry();
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces($config->loader->namespaces->toArray());
     $loader->register();
     $loader->registerDirs(array(APPLICATION_PATH . "/plugins/"));
     $db = new \Phalcon\Db\Adapter\Pdo\Mysql(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname, "charset" => $config->database->charset));
     $di->set('db', $db);
     $view = new \Phalcon\Mvc\View();
     define('MAIN_VIEW_PATH', '../../../views/');
     $view->setMainView(MAIN_VIEW_PATH . 'main');
     $view->setLayoutsDir(MAIN_VIEW_PATH . '/layouts/');
     $view->setPartialsDir(MAIN_VIEW_PATH . '/partials/');
     $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
     $volt->setOptions(array('compiledPath' => APPLICATION_PATH . '/cache/volt/'));
     $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
     $viewEngines = array(".volt" => $volt, ".phtml" => $phtml);
     $registry->viewEngines = $viewEngines;
     $view->registerEngines($viewEngines);
     if (isset($_GET['_ajax']) && $_GET['_ajax']) {
         $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
     }
     $di->set('view', $view);
     $viewSimple = new \Phalcon\Mvc\View\Simple();
     $viewSimple->registerEngines($viewEngines);
     $di->set('viewSimple', $viewSimple);
     $url = new \Phalcon\Mvc\Url();
     $url->setBasePath('/');
     $url->setBaseUri('/');
     $cacheFrontend = new \Phalcon\Cache\Frontend\Data(array("lifetime" => 60, "prefix" => HOST_HASH));
     switch ($config->cache) {
         case 'file':
             $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, array("cacheDir" => __DIR__ . "/cache/backend/"));
             break;
         case 'memcache':
             $cache = new \Phalcon\Cache\Backend\Memcache($cacheFrontend, array("host" => "localhost", "port" => "11211"));
             break;
     }
     $di->set('cache', $cache);
     $di->set('modelsCache', $cache);
     switch ($config->metadata_cache) {
         case 'memory':
             $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
             break;
         case 'apc':
             $modelsMetadata = new \Phalcon\Mvc\Model\MetaData\Apc(array("lifetime" => 60, "prefix" => HOST_HASH));
             break;
     }
     $di->set('modelsMetadata', $modelsMetadata);
     /**
      * CMS Конфигурация
      */
     $cmsModel = new \Cms\Model\Configuration();
     $cms = $cmsModel->getConfig();
     // @todo Будет отдельный раздел конфигурации для управления языками. Пока заглушка.
     $cms['languages'] = [['name' => 'Русский', 'iso' => 'ru', 'locale' => 'ru_RU'], ['name' => 'English', 'iso' => 'en', 'locale' => 'en_EN']];
     $registry->cms = $cms;
     // Отправляем в Registry
     $application = new \Phalcon\Mvc\Application();
     $application->registerModules($config->modules->toArray());
     $router = new \Application\Mvc\Router\DefaultRouter();
     foreach ($application->getModules() as $module) {
         $className = str_replace('Module', 'Routes', $module['className']);
         if (class_exists($className)) {
             $class = new $className();
             $router = $class->init($router);
         }
     }
     $di->set('router', $router);
     $eventsManager = new \Phalcon\Events\Manager();
     $dispatcher = new \Phalcon\Mvc\Dispatcher();
     $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher, $di) use($di) {
         new LocalizationPlugin($dispatcher);
         new AclPlugin($di->get('acl'), $dispatcher);
     });
     $profiler = new \Phalcon\Db\Profiler();
     $eventsManager->attach('db', function ($event, $db) use($profiler) {
         if ($event->getType() == 'beforeQuery') {
             $profiler->startProfile($db->getSQLStatement());
         }
         if ($event->getType() == 'afterQuery') {
             $profiler->stopProfile();
         }
     });
     $db->setEventsManager($eventsManager);
     $di->set('profiler', $profiler);
     $dispatcher->setEventsManager($eventsManager);
     $di->set('dispatcher', $dispatcher);
     $session = new \Phalcon\Session\Adapter\Files();
     $session->start();
     $di->set('session', $session);
     $acl = new \Application\Acl\DefaultAcl();
     $di->set('acl', $acl);
     $assets = new \Phalcon\Assets\Manager();
     $di->set('assets', $assets);
     $flash = new \Phalcon\Flash\Session(array('error' => 'ui red inverted segment', 'success' => 'ui green inverted segment', 'notice' => 'ui blue inverted segment', 'warning' => 'ui orange inverted segment'));
     $di->set('flash', $flash);
     $di->set('helper', new \Application\Mvc\Helper());
     $di->set('registry', $registry);
     $assetsManager = new \Phalcon\Assets\Manager();
     $di->set('assets', $assetsManager);
     $application->setDI($di);
     $this->dispatch($di);
 }