コード例 #1
0
 public function testGetBaseDirectory()
 {
     $filesystem = new FileSystem();
     $tmp = sys_get_temp_dir();
     $directory = Utilities::getBaseDirectory($filesystem);
     $this->assertStringStartsWith($tmp, $directory, 'Base directory is placed inside the system temp directory.');
     $this->assertTrue(is_dir($directory), 'Base Directory exists and is a directory');
     $this->assertTrue(touch($directory . 'test'), 'Base Directory is writeable.');
 }
コード例 #2
0
ファイル: Sqlite.php プロジェクト: Twizanex/GuildWoW
 /**
  *
  * @param  array                             $options
  * @throws \Stash\Exception\RuntimeException
  */
 public function setOptions(array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     $cachePath = isset($options['path']) ? $options['path'] : Utilities::getBaseDirectory($this);
     $this->cachePath = rtrim($cachePath, '\\/') . '/';
     Utilities::checkFileSystemPermissions($this->cachePath, $this->dirPerms);
     $extension = isset($options['extension']) ? strtolower($options['extension']) : 'any';
     $version = isset($options['version']) ? $options['version'] : 'any';
     $subdrivers = array();
     if (Sub\SqlitePdo::isAvailable()) {
         $subdrivers['pdo'] = '\\Stash\\Driver\\Sub\\SqlitePdo';
     }
     if (Sub\Sqlite::isAvailable()) {
         $subdrivers['sqlite'] = '\\Stash\\Driver\\Sub\\Sqlite';
     }
     if (Sub\SqlitePdo2::isAvailable()) {
         $subdrivers['pdo2'] = '\\Stash\\Driver\\Sub\\SqlitePdo2';
     }
     if ($extension == 'pdo' && $version != '2' && isset($subdrivers['pdo'])) {
         $driver = $subdrivers['pdo'];
     } elseif ($extension == 'sqlite' && isset($subdrivers['sqlite'])) {
         $driver = $subdrivers['sqlite'];
     } elseif ($extension == 'pdo' && $version != '3' && isset($subdrivers['pdo2'])) {
         $driver = $subdrivers['pdo2'];
     } elseif (count($subdrivers) > 0 && $extension == 'any') {
         $driver = reset($subdrivers);
     } else {
         throw new RuntimeException('No sqlite extension available.');
     }
     $this->driverClass = $driver;
     $this->filePerms = $options['filePermissions'];
     $this->dirPerms = $options['dirPermissions'];
     $this->busyTimeout = $options['busyTimeout'];
     $this->nesting = $options['nesting'];
     $this->checkStatus();
 }
コード例 #3
0
 public static function tearDownAfterClass()
 {
     Utilities::deleteRecursive(Utilities::getBaseDirectory());
 }
コード例 #4
0
ファイル: FileSystem.php プロジェクト: epsylon/Hydra-dev
 /**
  * Requests a list of options.
  *
  * @param array $options
  *
  * @throws \Stash\Exception\RuntimeException
  */
 protected function setOptions(array $options = array())
 {
     $options += $this->getDefaultOptions();
     if (!isset($options['path'])) {
         $options['path'] = Utilities::getBaseDirectory($this);
     }
     $this->cachePath = rtrim($options['path'], '\\/') . DIRECTORY_SEPARATOR;
     $this->filePermissions = $options['filePermissions'];
     $this->dirPermissions = $options['dirPermissions'];
     $this->directorySplit = max((int) $options['dirSplit'], 1);
     $this->memStoreLimit = max((int) $options['memKeyLimit'], 0);
     if (is_callable($options['keyHashFunction'])) {
         $this->keyHashFunction = $options['keyHashFunction'];
     } else {
         throw new RuntimeException('Key Hash Function is not callable');
     }
     if (isset($options['encoder'])) {
         $encoder = $options['encoder'];
         if (is_object($encoder)) {
             if (!$encoder instanceof EncoderInterface) {
                 throw new RuntimeException('Encoder object must implement EncoderInterface');
             }
             $this->encoder = new $encoder();
         } else {
             $encoderInterface = 'Stash\\Driver\\FileSystem\\EncoderInterface';
             $encoderClass = 'Stash\\Driver\\FileSystem\\' . $encoder . 'Encoder';
             if (class_exists($encoder) && in_array($encoderInterface, class_implements($encoder))) {
                 $this->encoder = new $encoder();
             } elseif (class_exists($encoderClass) && in_array($encoderInterface, class_implements($encoderClass))) {
                 $this->encoder = new $encoderClass();
             } else {
                 throw new RuntimeException('Invalid Encoder: ' . $encoder);
             }
         }
     }
     Utilities::checkFileSystemPermissions($this->cachePath, $this->dirPermissions);
 }
コード例 #5
0
ファイル: Sqlite.php プロジェクト: epsylon/Hydra-dev
 /**
  * {@inheritdoc}
  */
 public function getDefaultOptions()
 {
     return array('path' => Utilities::getBaseDirectory($this), 'filePermissions' => 0660, 'dirPermissions' => 0770, 'busyTimeout' => 500, 'nesting' => 0, 'subdriver' => 'PDO');
 }
コード例 #6
0
ファイル: FileSystem.php プロジェクト: yakamoz-fang/concrete
 /**
  * Requests a list of options.
  *
  * @param  array                             $options
  * @throws \Stash\Exception\RuntimeException
  */
 public function setOptions(array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     $this->cachePath = isset($options['path']) ? $options['path'] : Utilities::getBaseDirectory($this);
     $this->cachePath = rtrim($this->cachePath, '\\/') . DIRECTORY_SEPARATOR;
     $this->filePermissions = $options['filePermissions'];
     $this->dirPermissions = $options['dirPermissions'];
     if (!is_numeric($options['dirSplit']) || $options['dirSplit'] < 1) {
         $options['dirSplit'] = 1;
     }
     $this->directorySplit = (int) $options['dirSplit'];
     if (!is_numeric($options['memKeyLimit']) || $options['memKeyLimit'] < 1) {
         $options['memKeyLimit'] = 0;
     }
     if (is_callable($options['keyHashFunction'])) {
         $this->keyHashFunction = $options['keyHashFunction'];
     } else {
         throw new RuntimeException('Key Hash Function is not callable');
     }
     $this->memStoreLimit = (int) $options['memKeyLimit'];
     Utilities::checkFileSystemPermissions($this->cachePath, $this->dirPermissions);
 }
コード例 #7
0
ファイル: FileSystem.php プロジェクト: ibou77/elgg
 /**
  * {@inheritdoc}
  */
 public function getDefaultOptions()
 {
     return array('path' => Utilities::getBaseDirectory($this), 'filePermissions' => 0660, 'dirPermissions' => 0770, 'dirSplit' => 2, 'memKeyLimit' => 20, 'keyHashFunction' => 'md5');
 }