本文整理汇总了PHP中League\Flysystem\FilesystemInterface::createDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::createDir方法的具体用法?PHP FilesystemInterface::createDir怎么用?PHP FilesystemInterface::createDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::createDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: directory
/**
* Get directory walker.
*
* @param string $path
* @param callable $callable
*
* @return static
*/
public function directory($path, callable $callable = null)
{
$directory_path = $this->makePath($path);
$this->outbox->createDir($directory_path);
$context = clone $this->context;
$context->directory = $directory_path;
$sub = new static($this->outbox, $this->stubbox, $context);
if ($callable) {
call_user_func($callable, $sub);
}
return $sub;
}
示例2: create
public function create(User $_user, string $extension, string $mime_type, string $original_name, string $temp_location, bool $is_image)
{
$query = "INSERT INTO `file` (user_id, extension, mime_type, md5, original_name, date_added, is_image)\n\t\t\t\t\t VALUES (:u, :e, :mt, :m, :o, :d, :i)";
$this->_pdo->perform($query, ["u" => $this->user_id = $_user->getId(), "e" => $this->extension = $extension, "mt" => $this->mime_type = $mime_type, "m" => $this->md5 = md5_file($temp_location), "o" => $this->original_name = $original_name, "d" => $this->date_added = Utility::getDateTimeForMySQLDateTime(), "i" => $this->is_image = $is_image]);
$stream = fopen($temp_location, "r+");
if (!$this->_filesystem->has($this->getDirMain())) {
$this->_filesystem->createDir($this->getDirMain());
}
if (!$this->_filesystem->has($this->getDirSub())) {
$this->_filesystem->createDir($this->getDirSub());
}
$this->_filesystem->writeStream($this->getPath(), $stream, ["visibility" => AdapterInterface::VISIBILITY_PUBLIC]);
fclose($stream);
}
示例3: push
/**
* {@inheritdoc}
*/
public function push(BackupInterface $backup)
{
$backupDirectory = $backup->getName();
if (!$this->flysystem->has($backupDirectory) && !$this->flysystem->createDir($backupDirectory)) {
throw new DestinationException(sprintf('Unable to create backup directory "%s" in flysystem destination.', $backupDirectory));
}
$removedBackupFiles = $this->getFiles($backupDirectory);
/**
* @var FileInterface $backupFile
*/
foreach ($backup->getFiles() as $backupFile) {
if (isset($removedBackupFiles[$backupFile->getRelativePath()])) {
unset($removedBackupFiles[$backupFile->getRelativePath()]);
}
$path = $backupDirectory . '/' . $backupFile->getRelativePath();
try {
if ($this->flysystem->has($path)) {
if ($backupFile->getModifiedAt() > new \DateTime('@' . $this->flysystem->getTimestamp($path))) {
$resource = fopen($backupFile->getPath(), 'r');
$this->flysystem->updateStream($path, $resource);
fclose($resource);
}
} else {
$resource = fopen($backupFile->getPath(), 'r');
$this->flysystem->putStream($path, $resource);
fclose($resource);
}
} catch (\Exception $e) {
throw new DestinationException(sprintf('Unable to backup file "%s" to flysystem destination.', $backupFile->getPath()), 0, $e);
}
}
/**
* @var FileInterface $removedBackupFile
*/
foreach ($removedBackupFiles as $removedBackupFile) {
$path = $backupDirectory . '/' . $removedBackupFile->getRelativePath();
try {
$this->flysystem->delete($path);
} catch (\Exception $e) {
throw new DestinationException(sprintf('Unable to cleanup backup destination "%s" after backup process, file "%s" could not be removed.', $backupDirectory, $path), 0, $e);
}
}
$this->removeEmptyDirectories($backupDirectory);
if (is_array($this->backups)) {
$this->backups[$backup->getName()] = $backup;
}
}
示例4: fetch
/**
* {@inheritdoc}
*/
public function fetch(FilesystemInterface $filesystem, $fileKey)
{
if (!$filesystem->has($fileKey)) {
throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $fileKey));
}
if (false === ($stream = $filesystem->readStream($fileKey))) {
throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
}
if (!$this->tmpFilesystem->has(dirname($fileKey))) {
$this->tmpFilesystem->createDir(dirname($fileKey));
}
$localPathname = $this->tmpFilesystem->getAdapter()->getPathPrefix() . $fileKey;
if (false === file_put_contents($localPathname, $stream)) {
throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
}
return new \SplFileInfo($localPathname);
}
示例5: touchDir
private function touchDir(FilesystemInterface $fs, string $entityId, string $collectionUID, string $imageId) : string
{
$resultPath = sprintf('%s/%s/%s', $entityId, $collectionUID, $imageId);
if (!$fs->has($resultPath)) {
$fs->createDir($resultPath);
}
return $resultPath;
}
示例6: _mkdir
/**
* Create dir and return created dir path or false on failed
*
* @param string $path parent dir path
* @param string $name new directory name
* @return string|bool
**/
protected function _mkdir($path, $name)
{
$path = $this->_joinPath($path, $name);
if ($this->fs->createDir($path)) {
return $path;
}
return false;
}
示例7: createFolder
/**
* Creates a folder, within a parent folder.
* If no parent folder is given, a root level folder will be created
*
* @param string $newFolderName
* @param string $parentFolderIdentifier
* @param bool $recursive
* @return string the Identifier of the new folder
*/
public function createFolder($newFolderName, $parentFolderIdentifier = '', $recursive = false)
{
$parentFolderIdentifier = $this->canonicalizeAndCheckFolderIdentifier($parentFolderIdentifier);
$newFolderName = trim($newFolderName, '/');
$newFolderName = $this->sanitizeFileName($newFolderName);
$newIdentifier = $parentFolderIdentifier . $newFolderName . '/';
$this->filesystem->createDir($newIdentifier);
return $newIdentifier;
}
示例8: createDir
/**
* Create a directory.
*
* @param string $dirname
* @param string $visibility
* @throws IoWriteException
*/
public function createDir($dirname, $visibility = self::VISIBILITY_DEFAULT)
{
try {
$this->fs->createDir($dirname, $this->prepareConfig($visibility));
} catch (Error $ex) {
throw new IoWriteException("Directory {$dirname} could not be created.", $ex);
} catch (Exception $ex) {
throw new IoWriteException("Directory {$dirname} could not be created.", $ex);
}
}
示例9: onGetClassGenerateFile
/**
* Use flysystem to save the file in the desired location.
*
* @param \Onema\ClassyFile\Event\GetClassEvent $event
*/
public function onGetClassGenerateFile(GetClassEvent $event)
{
$statement = $event->getStatements();
$fileLocation = $event->getFileLocation();
$code = $event->getCode();
$name = $statement->name;
if (!$this->filesystem->has($fileLocation)) {
// dir doesn't exist, make it
$this->filesystem->createDir($fileLocation);
}
$location = sprintf('%s/%s.php', $fileLocation, $name);
$this->filesystem->put($location, $code);
$adapter = $this->filesystem->getAdapter();
if ($adapter instanceof AbstractAdapter) {
$prefix = $adapter->getPathPrefix();
$location = Util::normalizePath($location);
$event->setFileLocation(sprintf('%s%s', $prefix, $location));
}
}
示例10: fetch
/**
* {@inheritdoc}
*/
public function fetch(FilesystemInterface $filesystem, $fileKey, array $options = [])
{
if (!$filesystem->has($fileKey)) {
throw new \LogicException(sprintf('The file "%s" is not present on the filesystem.', $fileKey));
}
if (false === ($stream = $filesystem->readStream($fileKey))) {
throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
}
if (!$this->tmpFilesystem->has(dirname($fileKey))) {
$this->tmpFilesystem->createDir(dirname($fileKey));
}
// TODO: we should not get the path prefix like that
// TODO: it should be injected in the constructor
$localPathname = $this->tmpFilesystem->getAdapter()->getPathPrefix() . $fileKey;
if (false === file_put_contents($localPathname, $stream)) {
throw new FileTransferException(sprintf('Unable to fetch the file "%s" from the filesystem.', $fileKey));
}
return new \SplFileInfo($localPathname);
}
示例11: createDir
/**
* @override
* @inheritDoc
*/
public function createDir($dirname, $visibility = self::VISIBILITY_DEFAULT)
{
try {
if ($this->exists($dirname)) {
$this->removeDir($dirname);
}
$this->fs->createDir($dirname, $this->prepareConfig($visibility));
return;
} catch (Error $ex) {
} catch (Exception $ex) {
}
throw new WriteException("Directory {$dirname} could not be created.", $ex);
}
示例12: create
/**
* Create a file or folder.
*
* @param string $path
* @param string|null $contents
*/
protected function create($path, $contents = null)
{
// If the file already exists, quit
$path = $this->formatPath($path);
if ($this->filesystem->has($path)) {
return;
}
// Create the file or folder
if ($contents) {
$this->filesystem->put($path, $contents);
} else {
$this->filesystem->createDir($path);
}
$this->output->writeln('<info>✓</info> Created <comment>' . $path . '</comment>');
}
示例13: makeDirectory
/**
* Create a directory.
*
* @param string $path
* @return bool
*/
public function makeDirectory($path)
{
return $this->driver->createDir($path);
}
示例14: createDirectory
/**
* @param string $directory
* @throws SaveResourceErrorException
* @see \Staticus\Resources\Middlewares\SaveResourceMiddlewareAbstract::createDirectory
*/
protected function createDirectory($directory)
{
if (!$this->filesystem->createDir($directory)) {
throw new SaveResourceErrorException('Can\'t create a directory: ' . $directory);
}
}
示例15: _mkdir
/**
* Create dir and return created dir path or false on failed
*
* @param string $path parent dir path
* @param string $name new directory name
* @return string|bool
**/
protected function _mkdir($path, $name)
{
$path = $this->_joinPath($path, $name);
return $this->_resultPath($this->fs->createDir($path), $path);
}