Ejemplo n.º 1
0
 /**
  * Return search specs
  *
  * @param string $filename config file name
  *
  * @return array
  */
 public function get($filename)
 {
     // Load data if it is not already in the object's cache:
     if (!isset($this->searchSpecs[$filename])) {
         // Connect to searchspecs cache:
         $sm = $this->getServiceLocator();
         $cache = is_object($sm) && $sm->has('CacheManager') ? $sm->get('CacheManager')->getCache('searchspecs') : false;
         // Determine full configuration file path:
         $fullpath = Reader::getBaseConfigPath($filename);
         $local = Reader::getLocalConfigPath($filename);
         // Generate cache key:
         $key = $filename . '-' . filemtime($fullpath);
         if (!empty($local)) {
             $key .= '-local-' . filemtime($local);
         }
         $key = md5($key);
         // Generate data if not found in cache:
         if (!$cache || !($results = $cache->getItem($key))) {
             $results = Yaml::load(file_get_contents($fullpath));
             if (!empty($local)) {
                 $localResults = Yaml::load(file_get_contents($local));
                 foreach ($localResults as $key => $value) {
                     $results[$key] = $value;
                 }
             }
             if ($cache) {
                 $cache->setItem($key, $results);
             }
         }
         $this->searchSpecs[$filename] = $results;
     }
     return $this->searchSpecs[$filename];
 }
Ejemplo n.º 2
0
 /**
  * Disable auto-configuration.
  *
  * @return mixed
  */
 public function doneAction()
 {
     $config = ConfigReader::getLocalConfigPath('config.ini', null, true);
     $writer = new ConfigWriter($config);
     $writer->set('System', 'autoConfigure', 0);
     if (!$writer->save()) {
         return $this->forwardTo('Install', 'fixbasicconfig');
     }
     return $this->createViewModel(array('configDir' => dirname($config)));
 }
Ejemplo n.º 3
0
 /**
  * Display summary of installation status
  *
  * @return mixed
  */
 public function homeAction()
 {
     // If the cache is messed up, nothing is going to work right -- check that
     // first:
     $cache = $this->getServiceLocator()->get('CacheManager');
     if ($cache->hasDirectoryCreationError()) {
         return $this->redirect()->toRoute('install-fixcache');
     }
     // First find out which version we are upgrading:
     if (!isset($this->cookie->sourceDir) || !is_dir($this->cookie->sourceDir)) {
         return $this->forwardTo('Upgrade', 'GetSourceDir');
     }
     // Next figure out which version(s) are involved:
     if (!isset($this->cookie->oldVersion) || !isset($this->cookie->newVersion)) {
         return $this->forwardTo('Upgrade', 'EstablishVersions');
     }
     // Now make sure we have a configuration file ready:
     if (!isset($this->cookie->configOkay)) {
         return $this->redirect()->toRoute('upgrade-fixconfig');
     }
     // Now make sure the database is up to date:
     if (!isset($this->cookie->databaseOkay)) {
         return $this->redirect()->toRoute('upgrade-fixdatabase');
     }
     // Check for missing metadata in the resource table; note that we do a
     // redirect rather than a forward here so that a submit button clicked
     // in the database action doesn't cause the metadata action to also submit!
     if (!isset($this->cookie->metadataOkay)) {
         return $this->redirect()->toRoute('upgrade-fixmetadata');
     }
     // We're finally done -- display any warnings that we collected during
     // the process.
     $allWarnings = array_merge(isset($this->cookie->warnings) ? $this->cookie->warnings : array(), (array) $this->session->warnings);
     foreach ($allWarnings as $warning) {
         $this->flashMessenger()->setNamespace('info')->addMessage($warning);
     }
     return $this->createViewModel(array('configDir' => dirname(ConfigReader::getLocalConfigPath('config.ini', null, true)), 'importDir' => LOCAL_OVERRIDE_DIR . '/import'));
 }