예제 #1
0
 /**
  * Adds a cache to the stack specification
  *
  * @param  \LayerCache\Cache\CachingLayer|string $cache
  * @return \LayerCache\StackBuilder
  */
 public function addLayer($cache)
 {
     if (is_object($cache)) {
         if (!$cache instanceof CachingLayer) {
             throw new \LayerCache\Exception('Cache should implement \\LayerCache\\Cache\\CachingLayer interface!');
         }
         $obj = $cache;
     } elseif (is_string($cache)) {
         if (!$this->cacheMap->has($cache)) {
             throw new \LayerCache\Exception("No named cache found: '{$cache}'");
         }
         $obj = $this->cacheMap->get($cache);
     } else {
         throw new Exception('Cache should be an object or a string');
     }
     $this->currentLayer = $this->createLayer($obj);
     $this->layers[] = $this->currentLayer;
     return $this;
 }
예제 #2
0
 /**
  * Returns true if the named stack exists, false otherwise
  *
  * @static
  * @param  string $name
  * @return bool
  */
 public static function hasStack($name)
 {
     return self::$stackMap && self::$stackMap->has($name);
 }