コード例 #1
0
 /**
  * {@inheritDoc}
  *
  * @return HtmlCache
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // Configure the cache
     $config = $serviceLocator->get('Config');
     $cacheConfig = isset($config['cache']) ? $config['cache'] : array();
     $cache = StorageFactory::factory($cacheConfig);
     return new HtmlCache($cache);
 }
コード例 #2
0
ファイル: Storage.php プロジェクト: mbcraft/piol
 /**
  * 
  * Construct a Storage instance placed inside the specified folder with the specified name,
  * of the specified type.
  * 
  * @param string $folder the folder name, as a string.
  * @param string $name the storage file name, as a string.
  * @param string $storage_t the storage file, actually the file extension.
  * @throws \Mbcraft\Piol\IOException if the parameters does not point to a valid storage location.
  * 
  * @internal
  */
 protected function __construct($folder, $name, $storage_t)
 {
     /*
      if (!preg_match(self::VALID_FOLDER_AND_STORAGE_NAME_PATTERN,$folder))
      throw new IOException("Nome del folder non valido!");
     
      if (!preg_match(self::VALID_FOLDER_AND_STORAGE_NAME_PATTERN,$name))
      throw new IOException("Nome del file non valido!");
     */
     $this->folder = $folder;
     $this->name = $name;
     $storage_dir = StorageFactory::getProtectedStorage();
     $this->storage_type = $storage_t;
     $p = $storage_dir->getPath() . $folder . DS;
     $this->storage_dir = new Dir($p);
     if (!FileSystemUtils::isValidFilename($name . "." . $storage_t)) {
         throw new IOException("The specified string is not a valid filename.");
     }
     $p = $storage_dir->getPath() . $folder . DS . $name . DOT . $storage_t;
     $this->storage_file = new File($p);
 }
コード例 #3
0
 private function getStorage()
 {
     return StorageFactory::getStorage($this->_engine, '__orc__timer');
 }
コード例 #4
0
ファイル: __FileSystemElement.php プロジェクト: mbcraft/piol
 /**
  * 
  * Returns the storage data of this element, using the standard protected storage.
  * Default uses properties storage.
  * Files are clustered by parent directory.
  * 
  * @param string $storage_type The type of storage to get.
  * 
  * @return StorageDrivers\PropertiesStorage the properties storage for this element.
  * 
  * @api
  */
 public function getAttachedStorage($storage_type = "ini")
 {
     if ($this->getPath() === "/") {
         $path_md5 = md5("");
     } else {
         $path_md5 = md5($this->getParentDir()->getPath());
     }
     $folder_name = "_" . substr($path_md5, 0, 1);
     $file_name = md5($this->getFullName());
     return StorageFactory::getByExtension($folder_name, $file_name, $storage_type);
 }
コード例 #5
0
 /**
  * Get a storage adapter.
  *
  * If a string is passed it tries to get the instance based on the previous set
  * configuration. The object is stored internally and can be returned at any time
  * again by calling this method with the same adapter name.
  *
  * If an array is passed a new adapter object is instantiated and returned. The
  * created object is NOT stored internally!
  *
  * @param mixed $adapterName string of adapter configuration or array of settings
  * @param boolean $renewObject Creates a new instance of the given adapter in the configuration
  * @throws RuntimeException
  * @return Gaufrette object as configured by first argument
  */
 public static function get($adapterName, $renewObject = false)
 {
     if (is_string($adapterName)) {
         $adapter = self::_getAdapter($adapterName);
         if (is_object($adapter) && $renewObject === false) {
             return $adapter;
         }
     }
     $fromConfigStore = true;
     if (is_array($adapterName)) {
         $adapter = $adapterName;
         $fromConfigStore = false;
         if (empty($adapter['adapterClass'])) {
             throw \RuntimeException('No adapter class specified!');
         }
     }
     if (isset($adapter['adapterOptions']) && !is_array($adapter['adapterOptions'])) {
         throw new \InvalidArgumentException(sprintf('The adapter options must be an array!'));
     }
     if (!isset($adapter['adapterOptions'])) {
         $adapter['adapterOptions'] = [];
     }
     if (empty($adapter['engine'])) {
         $adapter['engine'] = self::$defaultEngine;
     }
     if ($adapter['engine'] === self::GAUFRETTE_ENGINE) {
         $object = self::gaufretteFactory($adapter);
     }
     if ($adapter['engine'] === self::FLYSYSTEM_ENGINE) {
         $object = self::flysystemFactory($adapter);
     }
     if (isset($object)) {
         if ($fromConfigStore) {
             $_this = StorageFactory::getInstance();
             $_this->_adapterConfig[$adapterName]['object'] =& $object;
         }
         return $object;
     }
     throw new \RuntimeException(sprintf('Invalid engine %s!', $adapter['engine']));
 }