Esempio n. 1
0
 /**
  * Clear cache with "clear cache" command.
  */
 public function clear($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = null, $environment = self::DEFAULT_ENVIRONMENT)
 {
     $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
     define('APPLICATION_PATH', $this->_loadedProfile->search('applicationDirectory')->getPath());
     $config = Centurion_Config_Directory::loadConfig(APPLICATION_PATH . '/configs', $environment);
     $cacheManager = new Centurion_Cache_Manager();
     $options = $config['resources']['cachemanager'];
     foreach ($options as $key => $value) {
         if ($cacheManager->hasCacheTemplate($key)) {
             $cacheManager->setTemplateOptions($key, $value);
         } else {
             $cacheManager->setCacheTemplate($key, $value);
         }
     }
     if (null === $tags || !is_array($tags) && !is_string($tags)) {
         $tags = array();
     }
     if (is_string($tags)) {
         $tags = explode(',', $tags);
     }
     foreach ($cacheManager->getBackends() as $key => $cache) {
         $this->_registry->getResponse()->appendContent(sprintf(">>> (%s) %s", $key, get_class($cache)));
         if ($cache instanceof Zend_Cache_Backend_ExtendedInterface) {
             switch ($mode) {
                 case Zend_Cache::CLEANING_MODE_ALL:
                     $ids = $cache->getIds();
                     break;
                 case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
                     $ids = $cache->getIdsMatchingAnyTags($tags);
                     break;
                 case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
                     $ids = $cache->getIdsMatchingTags($tags);
                     break;
                 case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
                     $ids = $cache->getIdsNotMatchingTags($tags);
                     break;
                 case Zend_Cache::CLEANING_MODE_OLD:
                     $ids = $cache->getIds();
                     break;
             }
         } else {
             $this->_registry->getResponse()->appendContent('not extended');
         }
         $cache->clean($mode, $tags);
         if ($cache instanceof Zend_Cache_Backend_ExtendedInterface) {
             if ($mode === Zend_Cache::CLEANING_MODE_OLD) {
                 $ids = array_diff($ids, $cache->getIds());
             }
             if (count($ids)) {
                 foreach ($ids as $val) {
                     $this->_registry->getResponse()->appendContent(sprintf('>> %-9s %s', 'id-', $val));
                 }
             }
         }
     }
     if ($mode === Zend_Cache::CLEANING_MODE_ALL) {
         Centurion_Loader_PluginLoader::clean();
     }
 }
Esempio n. 2
0
 public function __construct($name = NULL, array $data = array(), $dataName = '')
 {
     if (null == $this->bootstrap) {
         // Assign and instantiate in one step:
         $this->bootstrap = new Centurion_Application(APPLICATION_ENV, Centurion_Config_Directory::loadConfig(APPLICATION_PATH . '/configs/', APPLICATION_ENV, true));
     }
     parent::__construct($name, $data, $dataName);
 }
Esempio n. 3
0
 /**
  * @throws Zend_Application_Exception
  * @param $environment
  * @param null $options
  */
 public function __construct($environment, $options = null)
 {
     $this->_environment = (string) $environment;
     require_once 'Zend/Loader/Autoloader.php';
     $this->_autoloader = Zend_Loader_Autoloader::getInstance();
     if (is_string($options) && is_dir($options)) {
         $config = Centurion_Config_Directory::loadConfig($options, $environment);
         $this->setOptions($config);
     } else {
         if (null !== $options) {
             if (is_string($options)) {
                 $options = $this->_loadConfig($options);
             } elseif ($options instanceof Zend_Config) {
                 $options = $options->toArray();
             } elseif (!is_array($options)) {
                 throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array');
             }
             $this->setOptions($options);
         }
     }
 }
Esempio n. 4
0
 protected function _checkDbConnect()
 {
     if (!$this->_hasCenturion || !$this->_hasZend) {
         $this->_checklist[] = array('code' => -1, 'canBeBetter' => true, 'isNotSecure' => false, 'text' => 'Database could not be checked (no Centurion or Zend)', 'alt' => '');
     } else {
         include_once __DIR__ . '/../../library/Centurion/Config/Directory.php';
         include_once __DIR__ . '/../../library/Centurion/Iterator/Directory.php';
         include_once __DIR__ . '/../../library/Zend/Config/Ini.php';
         $config = Centurion_Config_Directory::loadConfig(__DIR__ . '/../../application/configs', $this->_currentEnv);
         include_once __DIR__ . '/../../library/Zend/Application/Resource/Db.php';
         include_once __DIR__ . '/../../library/Zend/Db.php';
         $this->_dbRessource = new Zend_Application_Resource_Db();
         $this->_dbRessource->setParams($config['resources']['db']['params']);
         $this->_dbRessource->setAdapter($config['resources']['db']['adapter']);
         try {
             $bddVersion = $this->_dbRessource->getDbAdapter()->getServerVersion();
             if (version_compare(PHP_VERSION, '5.1') >= 0) {
                 $this->_checklist[] = array('code' => 1, 'canBeBetter' => false, 'isNotSecure' => false, 'text' => 'Mysql version <strong>' . $bddVersion . '</strong>', 'alt' => '');
             } else {
                 $this->_checklist[] = array('code' => -1, 'canBeBetter' => true, 'isNotSecure' => true, 'text' => 'Mysql version <strong>' . $bddVersion . '</strong>', 'alt' => '');
             }
         } catch (Exception $e) {
             if ($e->getCode() == 1049) {
                 $this->_checklist[] = array('code' => -1, 'canBeBetter' => true, 'isNotSecure' => true, 'text' => 'BDD  ' . $config['resources']['db']['params']['dbname'] . ' does not exists', 'alt' => '');
             } else {
                 throw $e;
             }
         }
     }
 }
Esempio n. 5
0
 /**
  * @covers Centurion_Config_Directory::loadConfig
  */
 public function testLoadConfigWithWrongParameter()
 {
     Centurion_Config_Directory::loadConfig(APPLICATION_PATH . '/../tests/support/configs/empty', 'test');
     $this->setExpectedException('Centurion_Exception');
     Centurion_Config_Directory::loadConfig(APPLICATION_PATH . '/../tests/support/this_diretory_does_not_exists', 'test');
 }
Esempio n. 6
0
 /**
  * Retrieve import adapter.
  *
  * @param string $environment 
  * @return Zend_Db_Adapter_Abstract
  */
 protected function _getDbImport($environment = self::DEFAULT_ENVIRONMENT)
 {
     if (null === $this->_dbImport) {
         if (!$this->_loadedProfile) {
             $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
         }
         define('APPLICATION_PATH', $this->_loadedProfile->search('applicationDirectory')->getPath());
         $config = Centurion_Config_Directory::loadConfig(dirname($this->_loadedProfile->search('applicationConfigFile')->getPath()), $environment);
         $dbAdapter = Zend_Db::factory(new Zend_Config($config['resources']['db']));
         $this->_dbImport = Centurion_Import::factory($dbAdapter);
     }
     return $this->_dbImport;
 }