Esempio n. 1
0
 /**
  * Gets a Piece_Right_Config object from a configuration file or a cache.
  *
  * @param string $masterFile
  * @param string $cacheDirectory
  * @return Piece_Right_Config
  */
 function &_getConfiguration($masterFile, $cacheDirectory)
 {
     $masterFile = realpath($masterFile);
     $cache =& new Cache_Lite_File(array('cacheDir' => "{$cacheDirectory}/", 'masterFile' => $masterFile, 'automaticSerialization' => true, 'errorHandlingAPIBreak' => true));
     if (!Piece_Right_Env::isProduction()) {
         $cache->remove($masterFile);
     }
     /*
      * The Cache_Lite class always specifies PEAR_ERROR_RETURN when
      * calling PEAR::raiseError in default.
      */
     $config = $cache->get($masterFile);
     if (PEAR::isError($config)) {
         trigger_error("Cannot read the cache file in the directory [ {$cacheDirectory} ].", E_USER_WARNING);
         return Piece_Right_Config_Factory::_getConfigurationFromFile($masterFile);
     }
     if (!$config) {
         $config =& Piece_Right_Config_Factory::_getConfigurationFromFile($masterFile);
         if (Piece_Right_Error::hasErrors()) {
             $return = null;
             return $return;
         }
         $result = $cache->save($config);
         if (PEAR::isError($result)) {
             trigger_error("Cannot write the Piece_Right_Config object to the cache file in the directory [ {$cacheDirectory} ].", E_USER_WARNING);
         }
     }
     return $config;
 }
Esempio n. 2
0
 /**
  * Invokes the plugin specific code.
  *
  * @param boolean $isProduction
  */
 function invoke($isProduction)
 {
     Piece_Right_Env::setIsProduction($isProduction);
 }
Esempio n. 3
0
 /**
  * Sets whether the current environment is production or not.
  *
  * @param boolean $isProduction
  */
 public function setIsProduction($isProduction)
 {
     Piece_Right_Env::setIsProduction($isProduction);
 }