/** * {@inheritDoc} */ public function getInfo($file) { if (!$this->exists($file)) { return false; } return array('file_size' => FileUtils::getContentSize($this->storage[$file]['content'])); }
/** * {@inheritDoc} */ public function transform($file, array $transformOptions = array(), array $parameters = array()) { $image = $this->imagine->open($file); foreach ($transformOptions as $transform => $args) { if ($transform == 'resize') { $image->resize(new Box($args[0], $args[1])); } else { if ($transform == 'rotate') { list($angle, $background) = array_pad($transformOptions['rotate'], 2, null); $image->rotate((int) $angle, $background); } } } $image->save($file, array('format' => FileUtils::getExtensionFromMime($parameters['mime_type']))); }
/** * {@inheritDoc} */ public function getMime() { return FileUtils::getMime($this->file); }
/** * @param $path * @param bool $withRoot * @param bool $withPath * @return mixed */ protected function normalizePath($path, $withRoot = false, $withPath = true) { $path = ($withRoot ? $this->root : null) . FileUtils::normalizePath(($withPath ? $this->path . '/' : '') . '/' . $path); return $path; }
/** * @param $path * @param bool $withRoot Set to true to prepend project root to the normalized path * @param $withBasePath * @return string */ public function normalizePath($path, $withRoot = false, $withBasePath = true) { $dir = null; if (!FileUtils::isAbsolute($path)) { $dir = ($withRoot ? $this->projectRoot . '/' : null) . ($withBasePath ? $this->savePath . '/' : null); } return FileUtils::normalizePath($dir . $path); }
/** * Creates an SQLiteConnection * * @param array $parameters Connection parameters * <pre> * database: eg my_app.db * </pre> * * @return \PDO */ public function createConnection($parameters) { $path = FileUtils::normalizePath($parameters['database']); $connection = new \PDO('sqlite:' . $path); return $connection; }
/** * @param string $oldName * @param array $transform * @return string */ protected function generateModifiedSaveName($oldName, $transform) { $name = $this->getTransformer()->generateName($transform); // Extract information from original file $directory = dirname($oldName); $originalName = pathinfo($oldName, PATHINFO_FILENAME); $extension = pathinfo($oldName, PATHINFO_EXTENSION); return FileUtils::normalizePath(sprintf('%s/%s-%s.%s', $directory, $originalName, $name, $extension)); }
public function testVerifyPathExists() { $storage = $this->createStorage($this->createBaseUrlImpl()); $path = FileUtils::normalizePath(__DIR__ . '/../../files/photo'); $this->assertEquals($path, $storage->verifyPathExists($path)); $this->setExpectedException('RuntimeException'); $storage->verifyPathExists('test/directory', false); }