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


PHP Filesystem::dumpFile方法代码示例

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


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

示例1: download

 /**
  * @return bool
  */
 public function download()
 {
     if ($this->isDownloaded()) {
         return true;
     }
     $httpClient = new Client();
     $request = new Request('GET', $this->getUrl());
     $response = $httpClient->send($request, [RequestOptions::PROGRESS => function ($total, $current) {
         if ($total <= 0 || !$this->output) {
             return;
         }
         if (!$this->progressBar) {
             $this->progressBar = new ProgressBar($this->output, $total);
             $this->progressBar->setPlaceholderFormatterDefinition('max', function (ProgressBar $bar) {
                 return $this->formatSize($bar->getMaxSteps());
             });
             $this->progressBar->setPlaceholderFormatterDefinition('current', function (ProgressBar $bar) {
                 return str_pad($this->formatSize($bar->getProgress()), 11, ' ', STR_PAD_LEFT);
             });
         }
         $this->progressBar->setProgress($current);
     }]);
     $this->filesystem->dumpFile($this->getDestinationFile(), $response->getBody()->getContents());
     $this->downloaded = true;
     return true;
 }
开发者ID:LinkValue,项目名称:MajoraInstaller,代码行数:29,代码来源:Downloader.php

示例2: createAction

 /**
  * @Route("/new", name="wiki_create")
  * @Method("POST")
  */
 public function createAction(Request $request)
 {
     $name = $request->request->get('name');
     $user = $this->getUser();
     $slug = $request->request->get('slug');
     if (empty($slug)) {
         $slug = $this->get('slug')->slugify($name);
     }
     $repositoryService = $this->get('app.repository');
     $repository = $repositoryService->createRepository($slug);
     $adminRepository = $repositoryService->getRepository($this->getParameter('app.admin_repository'));
     $path = $repository->getWorkingDir();
     $fs = new Filesystem();
     $fs->dumpFile($path . '/index.md', '# ' . $name);
     $repository->setDescription($name);
     $repository->run('add', array('-A'));
     $repository->run('commit', array('-m Initial commit', '--author="' . $user->getName() . ' <' . $user->getEmail() . '>"'));
     $username = $user->getUsername();
     $adminPath = $adminRepository->getWorkingDir();
     $yamlDumper = new Dumper();
     $yamlString = $yamlDumper->dump(array('groups' => null, 'owners' => array($username), 'users' => array($username => 'RW+')), 3);
     $fs->dumpFile($adminPath . '/wikis/' . $slug . '.yml', $yamlString);
     $adminMessage = sprintf('Added wiki %s', $slug);
     $adminRepository->run('add', array('-A'));
     $adminRepository->run('commit', array('-m ' . $adminMessage, '--author="' . $user->getName() . ' <' . $user->getEmail() . '>"'));
     return $this->redirectToRoute('page_show', array('slug' => $slug));
 }
开发者ID:gitdown-wiki,项目名称:gitdown-wiki,代码行数:31,代码来源:WikiController.php

示例3: create

 public function create(FileResource $fileResource)
 {
     $fileName = $fileResource->getFileName();
     $content = $this->codeGenerator->getOutput($fileResource->getClassSource());
     $this->filesystem->dumpFile($fileName, $content);
     return true;
 }
开发者ID:nulldevelopmenthr,项目名称:generator,代码行数:7,代码来源:FileGenerator.php

示例4: testMergeAbort

 public function testMergeAbort()
 {
     $filesystem = new Filesystem();
     $git = new Git();
     $git->init($this->directory);
     $git->setRepository($this->directory);
     // branch:master
     $filesystem->dumpFile($this->directory . '/test.txt', 'foo');
     $git->add('test.txt');
     $git->commit('master');
     // branch:develop
     $git->checkout->create('develop');
     $filesystem->dumpFile($this->directory . '/test.txt', 'bar');
     $git->add('test.txt');
     $git->commit('develop');
     // branch:master
     $git->checkout('master');
     $filesystem->dumpFile($this->directory . '/test.txt', 'baz');
     $git->add('test.txt');
     $git->commit('master');
     try {
         $git->merge('develop');
         $this->fail('$git->merge("develop") should fail');
     } catch (Exception $e) {
     }
     $git->merge->abort();
     $this->assertEquals('baz', file_get_contents($this->directory . '/test.txt'));
 }
开发者ID:szoper,项目名称:PHPGit,代码行数:28,代码来源:MergeCommandTest.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $directory = $input->getArgument('directory');
     $routes = $this->router->getRouteCollection()->all();
     $arrayRoutes = [];
     $arrayRoutesDev = [];
     foreach ($routes as $routeName => $routeObject) {
         $routeCompile = $routeObject->compile();
         if (strpos($routeName, "app_form_") === 0) {
             $emptyVars = [];
             $variables = $routeCompile->getVariables();
             foreach ($variables as $v) {
                 $emptyVars[$v] = '*' . $v . '*';
             }
             $url = $this->router->generate($routeName, $emptyVars, UrlGeneratorInterface::ABSOLUTE_PATH);
             //$urlProd = str_replace('', '', $url);
             $arrayRoute = ["url" => $url, "params" => $variables, "method" => $routeObject->getMethods()[0]];
             $arrayRoutes[$routeName] = $arrayRoute;
             $output->writeln($routeName . ' => ' . json_encode($arrayRoute));
             $arrayRoute['url'] = '/app_dev.php/' . $arrayRoute['url'];
             $arrayRoutesDev[$routeName] = $arrayRoute;
         }
     }
     $jsFile = "\n      var Router = (function () {\n          var Router = {};\n          Router.routes = %ROUTES%;\n          Router.generate = function (routeName, routeParams) {\n              if(typeof routeParams == 'undefined') routeParams = {};\n              var route = this.routes[routeName];\n              if (typeof route === 'undefined')\n                  return false;\n              var routeUrl = route.url;\n              var params = [];\n              for (var param in routeParams) {\n                  routeUrl = routeUrl.replace('*' + param + '*', routeParams[param]);\n              }\n              return {\n                  url: routeUrl,\n                  method: route.method\n              };\n          };\n          return Router;\n      })();";
     $fs->dumpFile($directory . '/router_prod.js', str_replace('%ROUTES%', json_encode($arrayRoutes), $jsFile));
     $fs->dumpFile($directory . '/router_dev.js', str_replace('%ROUTES%', json_encode($arrayRoutesDev), $jsFile));
 }
开发者ID:pixocode,项目名称:noostache,代码行数:28,代码来源:RouterCommand.php

示例6: add

 /**
  * @param string $contents
  * @return string
  */
 public function add($contents)
 {
     $path = $this->path();
     $this->filesystem->dumpFile($path, $contents);
     $this->files[] = $path;
     return $path;
 }
开发者ID:pekkis,项目名称:temporary-file-manager,代码行数:11,代码来源:TemporaryFileManager.php

示例7: postPersist

 /**
  * @param LifecycleEventArgs $args
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof StorageEntity && $this->fs->exists($entity->getPath()) && !$this->fs->exists($entity->getPath() . self::ID_FILE)) {
         $this->fs->dumpFile($entity->getPath() . self::ID_FILE, $entity->getId(), 0666);
     }
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:10,代码来源:Storage.php

示例8: store

 /**
  * {@inheritDoc}
  */
 public function store(BinaryInterface $binary, $path, $filter)
 {
     $this->filesystem->dumpFile(
         $this->getFilePath($path, $filter),
         $binary->getContent()
     );
 }
开发者ID:ataxel,项目名称:tp,代码行数:10,代码来源:WebPathResolver.php

示例9: testFileExists

 /**
  *
  */
 public function testFileExists()
 {
     $this->dumpEntity->setCarefully(true);
     $this->filesystem->dumpFile($this->filePath, 'test');
     $this->setExpectedException('Evheniy\\SitemapXmlBundle\\Exception\\DumpException', 'File "' . $this->filePath . '" already exists!');
     $this->dumpEntity->saveFile($this->filePath, 'test');
 }
开发者ID:evheniy,项目名称:SitemapXmlBundle,代码行数:10,代码来源:DumpEntityTest.php

示例10: prepareWorkingDirectory

    private function prepareWorkingDirectory()
    {
        $this->currentDirectory = getcwd();
        // create a tmp directory
        $tmpFile = tempnam(sys_get_temp_dir(), '');
        $fs = new Filesystem();
        if ($fs->exists($tmpFile)) {
            $fs->remove($tmpFile);
        }
        $fs->mkdir($tmpFile);
        chdir($tmpFile);
        $this->tmpDirectory = $tmpFile;
        $fs->mkdir('dir');
        $fs->dumpFile('file', 'This is a test file');
        $fs->dumpFile('dir/file', 'This is a test file in a directory');
        $commandLine = <<<'EOF'
git init;
git config user.email "you@example.com"
git config user.name "Your Name"
git add file;
git commit -m "adds file";
git tag 0.1.0 -m "Adds file";
git checkout -b branch1 master;
git add dir/file;
git commit -m "adds dir/file";
git tag 0.2.0 -m "Adds file";
git branch branch2
EOF;
        (new Process($commandLine))->mustRun();
    }
开发者ID:git-pull-request,项目名称:git,代码行数:30,代码来源:GitTestTrait.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     $handle = new Filesystem();
     $path = './' . $name;
     try {
         if ($handle->exists($path)) {
             // 抛出目录已存在错误
             throw new IOException('Directory exists!');
         }
         // 创建目录
         $handle->mkdir(array($path . '/posts', $path . '/themes/default/css'));
         // 创建文件
         $handle->touch(array($path . '/config.json', $path . '/posts/hello.md', $path . '/themes/default/index.tpl', $path . '/themes/default/post.tpl'));
         // 填充文件
         $handle->dumpFile($path . '/config.json', 'hello world');
         $handle->dumpFile($path . '/posts/hello.md', 'hello world');
         $handle->dumpFile($path . '/themes/default/index.tpl', 'index-tpl');
         $handle->dumpFile($path . '/themes/default/post.tpl', 'post-tpl');
     } catch (IOException $exception) {
         // 创建项目失败处理异常
         $output->writeln('failed!');
         exit;
     }
     // 输出成功
     $output->writeln('created!');
 }
开发者ID:blindshadow,项目名称:colo,代码行数:27,代码来源:InitCommand.php

示例12: dump

 /**
  * Dumps an array into the parameters.yml file.
  *
  * @param array $config
  */
 public function dump(array $config, $mode = 0777)
 {
     $values = ['parameters' => array_merge($this->getConfigValues(), $config)];
     $yaml = Yaml::dump($values);
     $this->fileSystem->dumpFile($this->configFile, $yaml, $mode);
     $this->fileSystem->remove(sprintf('%s/%s.php', $this->kernel->getCacheDir(), $this->kernel->getContainerCacheClass()));
 }
开发者ID:csbill,项目名称:csbill,代码行数:12,代码来源:ConfigWriter.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * @var $schema Schema
      */
     $schema = $this->application->getStorage()->getSchema();
     $debug = $input->getArgument('debug') == true;
     $fs = new Filesystem();
     $fs->dumpFile($this->application->getProject()->getPath('build php Storage Master.php'), $this->fenom->render("master", array('schema' => $schema)));
     if ($debug) {
         echo '- master' . PHP_EOL;
     }
     foreach ($schema->getModels() as $model) {
         $modelGenerator = $this->application->getManager()->create('Cti\\Storage\\Generator\\Model', array('model' => $model));
         $modelSource = $modelGenerator->getCode();
         $path = $this->application->getProject()->getPath('build php Storage Model ' . $model->getClassName() . 'Base.php');
         $fs->dumpFile($path, $modelSource);
         $repositoryGenerator = $this->application->getManager()->create('Cti\\Storage\\Generator\\Repository', array('model' => $model));
         $repositorySource = $repositoryGenerator->getCode();
         $path = $this->application->getProject()->getPath('build php Storage Repository ' . $model->getClassName() . 'Repository.php');
         $fs->dumpFile($path, $repositorySource);
         if ($debug) {
             echo '- generate ' . $model->getClassName() . PHP_EOL;
         }
         //            if($model->hasOwnQuery()) {
         //                $fs->dumpFile(
         //                    $this->application->getPath('build php Storage Query ' . $model->class_name . 'Select.php'),
         //                    $this->application->getManager()->create('Cti\Storage\Generator\Select', array(
         //                        'model' => $model
         //                    ))
         //                );
         //            }
     }
 }
开发者ID:cti,项目名称:storage,代码行数:34,代码来源:GenerateStorage.php

示例14: getArgs

 /**
  * @return array
  */
 public function getArgs()
 {
     $path = $this->getTemporaryPath();
     $paragraphs = $this->faker->paragraphs(rand(5, 50), true);
     $this->filesystem->dumpFile($path, $paragraphs);
     return [$path];
 }
开发者ID:php-school,项目名称:learn-you-php,代码行数:10,代码来源:MyFirstIo.php

示例15: loadWsdl

 /**
  * Load remote WSDL to local cache.
  *
  * @param string $url
  * @return string
  */
 public function loadWsdl($url)
 {
     $response = $this->guzzleClient->get($url)->send();
     $cacheFilePath = $this->getCachedWsdlPath($url);
     $this->fs->dumpFile($cacheFilePath, $response->getBody(true));
     return $cacheFilePath;
 }
开发者ID:antrampa,项目名称:crm,代码行数:13,代码来源:WsdlManager.php


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