Esempio n. 1
0
 public function requireAuthorization()
 {
     if (!$this->_storage['user']) {
         DC::getEventDispatcher()->dispatchEvent('security.unauthenticated');
     }
     return false;
 }
Esempio n. 2
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. 3
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. 4
0
 protected static function fireRouteNotFound($controllerName, $actionName)
 {
     DC::getEventDispatcher()->dispatchEvent('route.notFound');
     DC::getLogger()->add('Invalid action call:' . $controllerName . '->' . $actionName . '()');
 }
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;
 }
Esempio n. 6
0
 public function __call($method, $params)
 {
     $operation = substr($method, 0, 3);
     if (in_array($operation, array('get', 'set'))) {
         if (substr($method, -4) == 'Root') {
             $key = 'roots/' . strtolower(substr($method, 3, -4));
         } else {
             $key = strtolower(substr($method, 3));
         }
         if ($operation == 'get') {
             return $this->_vars->getDeepValue($key);
         } else {
             $this->_vars->setDeepValue($key, $params[0]);
             DC::getEventDispatcher()->dispatchEvent('environment.update', $key);
             return $this;
         }
     } else {
         return $this;
     }
 }