/** * Update database and models */ public function updateAllAction() { QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0'); ModelOperator::getInstance(DC::getEnvironment()->getUserClassesRoot() . 'db/')->updateDBForAllModels(); ModelOperator::getInstance()->generateAllModelClasses(); $this->writeln('DB updated'); }
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()); }
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)), '\\'); } } }
public function tmpFileAction() { if ($path = $this->request->getVar('p')) { if (!FSService::showFileAndExit(DC::getEnvironment()->getTmpRoot() . $path)) { $response = new Response('<h1>Requested content not found</h1>', 404); $response->send(); die; } } }
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; }
protected function createCV($params) { $appPath = DC::getEnvironment()->getApplicationRoot() . $params['app']; FSService::makeWritable($appPath . '/Views/' . strtolower($params['name'])); FSService::makeWritable($appPath . '/Controllers/'); $this->safeCreateFromTemplate($appPath . '/Controllers/' . $params['name'] . 'Controller.php', '_controller', $params); $this->safeCreateFromTemplate($appPath . '/Views/' . strtolower($params['name']) . '/default.slot', '_view_default', $params); }