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


PHP Filesystem\Filesystem类代码示例

本文整理汇总了PHP中Symfony\Component\Filesystem\Filesystem的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem类的具体用法?PHP Filesystem怎么用?PHP Filesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Filesystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cleanup

 public function cleanup($path)
 {
     // cleanup
     $filesystem = new Filesystem();
     $filesystem->remove($path);
     return true;
 }
开发者ID:lsv,项目名称:OneupUploaderBundle,代码行数:7,代码来源:FilesystemStorage.php

示例2: createFolders

 /**
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param array $files
  * @param $permission
  * @return int
  */
 public function createFolders(\Symfony\Component\Console\Output\OutputInterface $output, $files, $permission)
 {
     $dryRun = $this->getConfigurationHelper()->getDryRun();
     if (empty($files)) {
         $output->writeln('<comment>No files found.</comment>');
         return 0;
     }
     $fs = new Filesystem();
     try {
         if ($dryRun) {
             $output->writeln("<comment>Folders to be created with permission " . decoct($permission) . ":</comment>");
             foreach ($files as $file) {
                 $output->writeln($file);
             }
         } else {
             $output->writeln("<comment>Creating folders with permission " . decoct($permission) . ":</comment>");
             foreach ($files as $file) {
                 $output->writeln($file);
             }
             $fs->mkdir($files, $permission);
         }
     } catch (IOException $e) {
         echo "\n An error occurred while removing the directory: " . $e->getMessage() . "\n ";
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:GenerateTempFileStructureCommand.php

示例3: __destruct

 /**
  * Remove the extracted directory
  */
 public function __destruct()
 {
     if ($this->extractedPath) {
         $fileSystem = new Filesystem();
         $fileSystem->remove($this->extractedPath);
     }
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:10,代码来源:CsvReader.php

示例4: execute

 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return int|null|void
  *
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     /**
      * We load the options to work with
      */
     $options = $this->getUsableConfig($input);
     /**
      * Building the real directory or file to work in
      */
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($path)) {
         $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     }
     if (!is_file($path) && !is_dir($path)) {
         throw new Exception('Directory or file "' . $path . '" does not exist');
     }
     /**
      * Print dry-run message if needed
      */
     $this->printDryRunMessage($input, $output, $path);
     /**
      * Print all configuration block if verbose level allows it
      */
     $this->printConfigUsed($output, $options);
     $fileFinder = new FileFinder();
     $files = $fileFinder->findPHPFilesByPath($path);
     /**
      * Parse and fix all found files
      */
     $this->parseAndFixFiles($input, $output, $files, $options);
 }
开发者ID:jumbojett,项目名称:php-formatter,代码行数:42,代码来源:UseSortCommand.php

示例5: tearDown

 public function tearDown()
 {
     parent::tearDown();
     $this->app['storage']->close();
     $fs = new Filesystem();
     $fs->remove($this->baseDir);
 }
开发者ID:hyperlator,项目名称:Sismo,代码行数:7,代码来源:appTest.php

示例6:

 function it_uses_container_dump_to_create_the_cache(Filesystem $filesystem, ContainerDumperFactory $dumperFactory, ContainerBuilder $containerBuilder, PhpDumper $dumper)
 {
     $dumper->dump()->willReturn('file contents');
     $dumperFactory->create($containerBuilder)->willReturn($dumper);
     $this->dump($containerBuilder);
     $filesystem->dumpFile($this->path, 'file contents')->shouldHaveBeenCalled();
 }
开发者ID:adrianoaguiar,项目名称:symfony-container-generator,代码行数:7,代码来源:FilesystemSpec.php

示例7: setUp

 protected function setUp()
 {
     $fs = new Filesystem();
     if ($fs->exists(self::$cacheDir)) {
         $fs->remove(self::$cacheDir);
     }
 }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:7,代码来源:DumperTestCase.php

示例8: backup

 /**
  * @param Profile $profile
  * @param bool    $clear
  *
  * @return Backup[]
  *
  * @throws \Exception
  */
 public function backup(Profile $profile, $clear = false)
 {
     $scratchDir = $profile->getScratchDir();
     $processor = $profile->getProcessor();
     $filesystem = new Filesystem();
     if ($clear) {
         $this->logger->info('Clearing scratch directory...');
         $filesystem->remove($scratchDir);
     }
     if (!is_dir($scratchDir)) {
         $filesystem->mkdir($scratchDir);
     }
     $this->logger->info('Beginning backup...');
     foreach ($profile->getSources() as $source) {
         $source->fetch($scratchDir, $this->logger);
     }
     $filename = $processor->process($scratchDir, $profile->getNamer(), $this->logger);
     try {
         $backups = $this->sendToDestinations($profile, $filename);
     } catch (\Exception $e) {
         $processor->cleanup($filename, $this->logger);
         throw $e;
     }
     $processor->cleanup($filename, $this->logger);
     $this->logger->info('Done.');
     return $backups;
 }
开发者ID:kachkaev,项目名称:php-backup,代码行数:35,代码来源:Executor.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getApplication()->getContainer();
     $commandFile = realpath($_SERVER['SCRIPT_FILENAME']);
     $currentVersion = "v" . $container->getVersion();
     $updateVersion = trim(@file_get_contents('https://raw.githubusercontent.com/kohkimakimoto/altax/master/version'));
     if (!$container->isPhar()) {
         $output->writeln('<error>You can not update altax. Because altax only supports self-update command on PHAR file version.</error>');
         return 1;
     }
     if (!preg_match('/^v[0-9].[0-9]+.[0-9]+$/', $updateVersion)) {
         $output->writeln('<error>You can not update altax. Because the latest version of altax are not available for download.</error>');
         return 1;
     }
     if ($currentVersion === $updateVersion) {
         $output->writeln('<info>You are already using altax version <comment>' . $updateVersion . '</comment>.</info>');
         return 0;
     }
     $output->writeln(sprintf("Updating to version <info>%s</info>.", $updateVersion));
     $tmpDir = "/tmp/" . uniqid("altax.update.");
     $process = new Process("mkdir {$tmpDir} && cd {$tmpDir} && curl -L https://raw.githubusercontent.com/kohkimakimoto/altax/master/installer.sh | bash -s local {$updateVersion}");
     $process->setTimeout(null);
     if ($process->run() !== 0) {
         $output->writeln('<error>You can not update altax.');
         return 1;
     }
     $fs = new Filesystem();
     $fs->copy($tmpDir . "/altax.phar", $commandFile, true);
     $fs->remove($tmpDir);
     $output->writeln("Done.");
 }
开发者ID:kohkimakimoto,项目名称:altax,代码行数:31,代码来源:SelfUpdateCommand.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $finder = Finder::create()->in($this->cachePath)->notName('.gitkeep');
     $filesystem = new Filesystem();
     $filesystem->remove($finder);
     $output->writeln(sprintf("%s <info>success</info>", 'cache:clear'));
 }
开发者ID:ivoba,项目名称:superleansilexplate,代码行数:7,代码来源:ClearCacheCommand.php

示例11: tearDown

 public function tearDown()
 {
     // Delete local files
     $finder = new Finder();
     $fs = new Filesystem();
     $fs->remove($finder->files()->in($this->tmpDir . "/download"));
     $fs->remove($finder->files()->in($this->tmpDir));
     $fs->remove($this->tmpDir . "/download");
     $fs->remove($this->tmpDir);
     // Delete file uploads
     $options = new ListFilesOptions();
     $options->setTags(["docker-bundle-test"]);
     $files = $this->client->listFiles($options);
     foreach ($files as $file) {
         $this->client->deleteFile($file["id"]);
     }
     if ($this->client->bucketExists("in.c-docker-test")) {
         // Delete tables
         foreach ($this->client->listTables("in.c-docker-test") as $table) {
             $this->client->dropTable($table["id"]);
         }
         // Delete bucket
         $this->client->dropBucket("in.c-docker-test");
     }
     if ($this->client->bucketExists("in.c-docker-test-redshift")) {
         // Delete tables
         foreach ($this->client->listTables("in.c-docker-test-redshift") as $table) {
             $this->client->dropTable($table["id"]);
         }
         // Delete bucket
         $this->client->dropBucket("in.c-docker-test-redshift");
     }
 }
开发者ID:keboola,项目名称:input-mapping,代码行数:33,代码来源:StorageApiReaderTest.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $locator = $this->getContainer()->get('campaignchain.core.module.locator');
     $bundles = $locator->getAvailableBundles();
     $selectedBundle = $this->selectBundle($bundles);
     $generateOutput = new BufferedOutput();
     $application = new Application($this->getContainer()->get('kernel'));
     $application->setAutoExit(false);
     $application->run(new ArrayInput(['command' => $this->getDoctrineMigrationsCommand(), '--no-interaction' => true]), $generateOutput);
     preg_match('/Generated new migration class to "(.*)"/', $generateOutput->fetch(), $matches);
     if (count($matches) < 2) {
         //error
         return;
     }
     $pathForMigrationFile = $matches[1];
     preg_match('/Version.*.php/', $pathForMigrationFile, $fileNames);
     if (!count($fileNames)) {
         return;
     }
     $schemaFile = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..';
     $schemaFile .= DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $selectedBundle->getName();
     $schemaFile .= str_replace('/', DIRECTORY_SEPARATOR, $this->getContainer()->getParameter('campaignchain_update.bundle.schema_dir'));
     $schemaFile .= DIRECTORY_SEPARATOR . $fileNames[0];
     $fs = new Filesystem();
     $fs->copy($pathForMigrationFile, $schemaFile);
     $fs->remove($pathForMigrationFile);
     $this->io->success('Generation finished. You can find the file here:');
     $this->io->text($schemaFile);
 }
开发者ID:campaignchain,项目名称:update,代码行数:30,代码来源:GenerateBase.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configName = $input->getArgument('config-name');
     $editor = $input->getArgument('editor');
     $config = $this->getConfigFactory()->getEditable($configName);
     $configSystem = $this->getConfigFactory()->get('system.file');
     $temporalyDirectory = $configSystem->get('path.temporary') ?: '/tmp';
     $configFile = $temporalyDirectory . '/config-edit/' . $configName . '.yml';
     $ymlFile = new Parser();
     $fileSystem = new Filesystem();
     try {
         $fileSystem->mkdir($temporalyDirectory);
         $fileSystem->dumpFile($configFile, $this->getYamlConfig($configName));
     } catch (IOExceptionInterface $e) {
         throw new \Exception($this->trans('commands.config.edit.messages.no-directory') . ' ' . $e->getPath());
     }
     if (!$editor) {
         $editor = $this->getEditor();
     }
     $processBuilder = new ProcessBuilder(array($editor, $configFile));
     $process = $processBuilder->getProcess();
     $process->setTty('true');
     $process->run();
     if ($process->isSuccessful()) {
         $value = $ymlFile->parse(file_get_contents($configFile));
         $config->setData($value);
         $config->save();
         $fileSystem->remove($configFile);
     }
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
开发者ID:amira2r,项目名称:DrupalConsole,代码行数:36,代码来源:ConfigEditCommand.php

示例14: run

 /**
  * @param $offset
  *
  * @return FinishResult|ValidResult
  * @throws \RuntimeException
  * @throws \Exception
  */
 public function run($offset)
 {
     $fs = new Filesystem();
     $requestTime = time();
     try {
         $source = new Zip($this->source);
         $count = $source->count();
         $source->seek($offset);
     } catch (\Exception $e) {
         @unlink($this->source);
         throw new \Exception('Could not open update package:<br>' . $e->getMessage(), 0, $e);
     }
     /** @var ZipEntry $entry */
     while (list($position, $entry) = $source->each()) {
         $name = $entry->getName();
         $targetName = $this->destinationDir . $name;
         if (!$entry->isDir()) {
             $fs->dumpFile($targetName, $entry->getContents());
         }
         if (time() - $requestTime >= 20 || ($position + 1) % 1000 == 0) {
             $source->close();
             return new ValidResult($position + 1, $count);
         }
     }
     $source->close();
     return new FinishResult($count, $count);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:34,代码来源:UnpackStep.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Ask for an app and environment.
     $this->getApp($input, $output);
     $this->getEnvironment($input, $output);
     $environment_name = $this->environment->name;
     $app_name = $this->app->name;
     // Confirm removal of the app.
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion("Are you sure you would like to remove the environment <question>{$app_name}:{$environment_name}</question>?  All files at {$this->environment->path} will be deleted, and all containers will be killed. [y/N] ", false);
     if (!$helper->ask($input, $output, $question)) {
         $output->writeln('<error>Cancelled</error>');
         return;
     } else {
         // Remove the environment from config registry.
         // @TODO: Move this to EnvironmentFactory class
         // Remove files
         $fs = new Filesystem();
         try {
             $fs->remove(array($this->environment->path));
             $output->writeln("<info>Files for environment {$app_name}:{$environment_name} has been deleted.</info>");
         } catch (IOExceptionInterface $e) {
             $output->writeln('<error>Unable to remove ' . $e->getPath() . '</error>');
         }
         // Destroy the environment
         $environmentFactory = new EnvironmentFactory($this->environment, $this->app);
         $environmentFactory->destroy();
         unset($this->app->environments[$environment_name]);
         $this->getApplication()->getTerra()->getConfig()->add('apps', $app_name, (array) $this->app);
         $this->getApplication()->getTerra()->getConfig()->save();
         $output->writeln("<info>Environment {$app_name}:{$environment_name} has been removed.</info>");
     }
 }
开发者ID:badri,项目名称:terra-app,代码行数:33,代码来源:EnvironmentRemove.php


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