/** * @return $this */ public function load() { $phpFiles = $this->fileManager->findFiles('Hook' . DIRECTORY_SEPARATOR . '*.php'); foreach ($phpFiles as $phpFile) { require_once $phpFile; $loadedClasses = get_declared_classes(); $class = end($loadedClasses); $reflector = new \ReflectionClass($class); $parentClass = $reflector->getParentClass(); if ($parentClass) { $shortNameClass = str_replace('Fraym\\Hook\\', 'Fraym\\', $reflector->getName()); $shortNameClassHook = $parentClass->getName(); if ($shortNameClass === $shortNameClassHook) { $this->serviceLocator->set($parentClass->name, $this->serviceLocator->get($class)); $this->_hooks[$class] = $parentClass->name; } } } return $this; }
/** * @return bool */ protected function install() { if ($this->writeConfig($this->_configFile)) { // Disable max script exec time, because creating database shema takes some time set_time_limit(0); include_once $this->_configFile; $this->serviceLocator->set('db.options', ['driver' => DB_DRIVER, 'user' => DB_USER, 'password' => DB_PASS, 'host' => DB_HOST, 'dbname' => DB_NAME, 'charset' => DB_CHARSET]); $this->cache->clearAll(); $this->db->connect()->getSchemaTool()->dropDatabase(); $this->db->createSchema(); if (($errors = $this->initConfigurations()) !== true) { unlink($this->_configFile); $this->view->assign('error', implode('<br />', $errors)); return false; } return true; } return false; }