CMS\Config::get PHP Method

get() public static method

public static get ( )
    public static function get()
    {
        $application = (include_once APPLICATION_PATH . '/config/environment/' . APPLICATION_ENV . '.php');
        $config_default = ['loader' => ['namespaces' => ['YonaCMS\\Plugin' => APPLICATION_PATH . '/plugins/', 'Application' => APPLICATION_PATH . '/modules/Application', 'Cms' => APPLICATION_PATH . '/modules/Cms']], 'modules' => ['cms' => ['className' => 'Cms\\Module', 'path' => APPLICATION_PATH . '/modules/Cms/Module.php']], 'base_path' => isset($application['base_path']) ? $application['base_path'] : null, 'database' => isset($application['database']) ? $application['database'] : null, 'cache' => isset($application['cache']) ? $application['cache'] : null, 'memcache' => isset($application['memcache']) ? $application['memcache'] : null, 'memcached' => isset($application['memcached']) ? $application['memcached'] : null, 'assets' => isset($application['assets']) ? $application['assets'] : null];
        $global = (include_once APPLICATION_PATH . '/config/global.php');
        // Modules configuration list
        $modules_list = (include_once APPLICATION_PATH . '/config/modules.php');
        require_once APPLICATION_PATH . '/modules/Application/Loader/Modules.php';
        $modules = new \Application\Loader\Modules();
        $modules_config = $modules->modulesConfig($modules_list);
        $config = array_merge_recursive($config_default, $global, $modules_config);
        return new \Phalcon\Config($config);
    }

Usage Example

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);
 }
Config