Example #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);
 }