Esempio n. 1
0
 protected function loadSystemDependencies()
 {
     $initialDependencies = new YamlStorage(__DIR__ . '/kernel.dependencies.yml');
     $this->_dependencyContainer->addDependencies($initialDependencies, false);
     $this->_eventDispatcher = DC::getEventDispatcher();
     $this->_environment = Environment::createFromContext();
     DC::getAutoloader()->register(false)->registerNamespaceSharedPaths($this->_environment->getUserClassesRoot() . 'classes');
 }
Esempio n. 2
0
 public function detectApplication()
 {
     DC::getEventDispatcher()->dispatchEvent('route.buildRequest', Request::getIncomeRequest());
     $this->_name = 'console';
     $this->_config = array('uri' => 'solve/', 'path' => 'SolveConsole/');
     $this->_namespace = 'SolveConsole';
     $this->_root = realpath(__DIR__ . '/../SolveConsole/') . '/';
     DC::getAutoloader()->registerNamespacePath($this->_namespace, realpath(__DIR__ . '/../') . '/');
     ControllerService::setActiveNamespace($this->_namespace);
     return $this->_name;
 }
Esempio n. 3
0
 public function onEnvironmentUpdate(BaseEvent $event)
 {
     ConfigService::setConfigsPath(DC::getEnvironment()->getConfigRoot());
     ConfigService::loadAllConfigs();
     DC::getLogger()->setLogsPath(DC::getEnvironment()->getTmpRoot() . 'log');
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot(), true);
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'db/bases');
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'db/classes');
     DC::getAutoloader()->registerNamespaceSharedPaths(DC::getEnvironment()->getUserClassesRoot() . 'classes/', true);
     FilesAbility::setBaseStoreLocation(DC::getEnvironment()->getUploadRoot());
 }
Esempio n. 4
0
 public function configure()
 {
     parent::configure();
     $this->_slot = new Slot();
     $this->_slot->setTemplateDir($this->_view->getTemplatesPath());
     $this->_slot->setCompileDir(DC::getEnvironment()->getTmpRoot() . 'templates/' . DC::getApplication()->getName() . '/');
     $fs = new FSService();
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'helpers');
     if ($files = $fs->in(DC::getEnvironment()->getUserClassesRoot() . 'helpers')->find('*Block.php')) {
         foreach ($files as $file) {
             $this->_slot->registerBlock(Inflector::underscore(substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1, -9)), '\\');
         }
     }
 }
Esempio n. 5
0
 public function detectApplication()
 {
     DC::getEventDispatcher()->dispatchEvent('route.buildRequest', Request::getIncomeRequest());
     /**
      * @var ArrayStorage $appList
      */
     $appList = DC::getProjectConfig('applications');
     if (empty($appList)) {
         throw new \Exception('Empty application list');
     }
     $defaultAppName = DC::getProjectConfig('defaultApplication', 'frontend');
     $this->_name = $defaultAppName;
     $uri = (string) Request::getIncomeRequest()->getUri();
     $uriParts = explode('/', $uri);
     $webRoot = DC::getRouter()->getWebRoot();
     if (strlen($webRoot) > 1) {
         if (strpos($uri, substr($webRoot, 1)) === 0) {
             $uriParts = explode('/', substr($uri, strlen($webRoot)));
         }
     }
     if (!empty($uriParts) && (count($uriParts) > 0 && $uriParts[0] != '/')) {
         foreach ($appList as $appName => $appParams) {
             if ($appName == $defaultAppName) {
                 continue;
             }
             $appUri = !empty($appParams['uri']) ? $appParams['uri'] : $appName;
             if (strpos($uriParts[0], $appUri) === 0) {
                 array_shift($uriParts);
                 Request::getIncomeRequest()->setUri((strlen($webRoot) > 1 ? $webRoot . '/' : '') . implode('/', $uriParts));
                 $this->_name = $appName;
                 break;
             }
         }
     }
     $this->_config = DC::getProjectConfig('applications/' . $this->_name);
     if (!is_array($this->_config)) {
         $this->_config = array('uri' => $this->_name);
     }
     if (empty($this->_config['path'])) {
         $this->_config['path'] = Inflector::camelize($this->_name) . '/';
     }
     $this->_namespace = Inflector::camelize($this->_name);
     $this->_root = DC::getEnvironment()->getApplicationRoot() . $this->_config['path'];
     DC::getAutoloader()->registerNamespacePath($this->_namespace, DC::getEnvironment()->getApplicationRoot());
     ControllerService::setActiveNamespace($this->_namespace);
     return $this->_name;
 }