当前位置: 首页>>代码示例>>PHP>>正文


PHP FilesystemInterface::createDir方法代码示例

本文整理汇总了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;
 }
开发者ID:jumilla,项目名称:php-source-generator,代码行数:20,代码来源:FileGenerator.php

示例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);
 }
开发者ID:stevenimle,项目名称:GMA,代码行数:14,代码来源:File.php

示例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;
     }
 }
开发者ID:runopencode,项目名称:backup,代码行数:50,代码来源:FlysystemDestination.php

示例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);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:20,代码来源:FileFetcher.php

示例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;
 }
开发者ID:cass-project,项目名称:cass,代码行数:8,代码来源:MockAvatarStrategy.php

示例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;
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:15,代码来源:ElFinderVolumeFlysystem.php

示例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;
 }
开发者ID:cedricziel,项目名称:fal-flysystem,代码行数:18,代码来源:FlysystemDriver.php

示例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);
     }
 }
开发者ID:khelle,项目名称:surume,代码行数:17,代码来源:Filesystem.php

示例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));
     }
 }
开发者ID:onema,项目名称:classyfile,代码行数:24,代码来源:GenerateClassFile.php

示例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);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:22,代码来源:FileFetcher.php

示例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);
 }
开发者ID:kraken-php,项目名称:framework,代码行数:17,代码来源:Filesystem.php

示例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>');
 }
开发者ID:bramdevries,项目名称:glue,代码行数:21,代码来源:BootstrapCommand.php

示例13: makeDirectory

 /**
  * Create a directory.
  *
  * @param  string  $path
  * @return bool
  */
 public function makeDirectory($path)
 {
     return $this->driver->createDir($path);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:10,代码来源:FilesystemAdapter.php

示例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);
     }
 }
开发者ID:kivagant,项目名称:staticus-core,代码行数:11,代码来源:ImagePostProcessingMiddlewareAbstract.php

示例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);
 }
开发者ID:hectorgarcia83,项目名称:plataforma_eliana,代码行数:12,代码来源:Driver.php


注:本文中的League\Flysystem\FilesystemInterface::createDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。