Esempio n. 1
0
 public function setUp()
 {
     $this->_cache = Cache::factory('Core', 'File', array('lifetime' => 1, 'automatic_serialization' => true), array('cache_dir' => __DIR__ . '/../_files/'));
     Data::setCache($this->_cache);
 }
Esempio n. 2
0
 /**
  * Sets a cache
  *
  * @param  \Zend\Cache\Frontend $cache Cache to set
  * @return void
  */
 public static function setCache(\Zend\Cache\Frontend $cache)
 {
     Data\Data::setCache($cache);
 }
Esempio n. 3
0
 /**
  * Sets class wide options, if no option was given, the actual set options will be returned
  *
  * @param  array  $options  Options to set
  * @throws \Zend\Date\Exception
  * @return Options array if no option was given
  */
 public static function setOptions(array $options = array())
 {
     if (empty($options)) {
         return self::$_options;
     }
     foreach ($options as $name => $value) {
         $name = strtolower($name);
         if (array_key_exists($name, self::$_options)) {
             switch ($name) {
                 case 'format_type':
                     if (strtolower($value) != 'php' && strtolower($value) != 'iso') {
                         throw new Exception("Unknown format type ({$value}) for dates, only 'iso' and 'php' supported", 0, null, $value);
                     }
                     break;
                 case 'fix_dst':
                     if (!is_bool($value)) {
                         throw new Exception("'fix_dst' has to be boolean", 0, null, $value);
                     }
                     break;
                 case 'extend_month':
                     if (!is_bool($value)) {
                         throw new Exception("'extend_month' has to be boolean", 0, null, $value);
                     }
                     break;
                 case 'cache':
                     if ($value === null) {
                         parent::$_cache = null;
                     } else {
                         if (!$value instanceof \Zend\Cache\Core) {
                             throw new Exception("Instance of Zend_Cache expected");
                         }
                         parent::$_cache = $value;
                         Data::setCache($value);
                     }
                     break;
                 case 'timesync':
                     if ($value === null) {
                         parent::$_defaultOffset = 0;
                     } else {
                         if (!$value instanceof TimeSync\Protocol) {
                             throw new Exception("Instance of Zend_TimeSync expected");
                         }
                         $date = $value->getInfo();
                         parent::$_defaultOffset = $date['offset'];
                     }
                     break;
             }
             self::$_options[$name] = $value;
         } else {
             throw new Exception("Unknown option: {$name} = {$value}");
         }
     }
 }