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


PHP Finder\SplFileInfo类代码示例

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


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

示例1: parse

 /**
  * @param      $string
  * @param null $path
  * @return string
  */
 public function parse($string, $path = null)
 {
     $headers = [];
     $parts = preg_split('/[\\n]*[-]{3}[\\n]/', $string, 3);
     if (count($parts) == 3) {
         $string = $parts[0] . "\n" . $parts[2];
         $headers = $this->yaml->parse($parts[1]);
     }
     $file = new SplFileInfo($path, '', '');
     $date = Carbon::createFromTimestamp($file->getMTime());
     $dateFormat = config('fizl-pages::date_format', 'm/d/Y g:ia');
     $headers['date_modified'] = $date->toDateTimeString();
     if (isset($headers['date'])) {
         try {
             $headers['date'] = Carbon::createFromFormat($dateFormat, $headers['date'])->toDateTimeString();
         } catch (\InvalidArgumentException $e) {
             $headers['date'] = $headers['date_modified'];
             //dd($e->getMessage());
         }
     } else {
         $headers['date'] = $headers['date_modified'];
     }
     $this->execute(new PushHeadersIntoCollectionCommand($headers, $this->headers));
     $viewPath = PageHelper::filePathToViewPath($path);
     $cacheKey = "{$viewPath}.headers";
     $this->cache->put($cacheKey, $headers);
     return $string;
 }
开发者ID:hscale,项目名称:fizl-pages,代码行数:33,代码来源:PageHeaderParser.php

示例2: addFile

 /**
  * @param \Phar $phar
  * @param SplFileInfo $file
  */
 private function addFile(\Phar $phar, SplFileInfo $file)
 {
     $path = $file->getRelativePathname();
     $content = file_get_contents($file);
     $content = preg_replace('{^#!/usr/bin/env php\\s*}', '', $content);
     $phar->addFromString($path, $content);
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:11,代码来源:PharTask.php

示例3: testRessources

 /**
  * @dataProvider schemaProvider
  */
 public function testRessources(SplFileInfo $testDirectory)
 {
     // 1. Cleanup generated
     $filesystem = new Filesystem();
     if ($filesystem->exists($testDirectory->getRealPath() . DIRECTORY_SEPARATOR . 'generated')) {
         $filesystem->remove($testDirectory->getRealPath() . DIRECTORY_SEPARATOR . 'generated');
     }
     $filesystem->mkdir($testDirectory->getRealPath() . DIRECTORY_SEPARATOR . 'generated');
     // 2. Generate
     $command = new GenerateCommand();
     $inputArray = new ArrayInput(['--config-file' => $testDirectory->getRealPath() . DIRECTORY_SEPARATOR . '.jane'], $command->getDefinition());
     $command->execute($inputArray, new NullOutput());
     // 3. Compare
     $expectedFinder = new Finder();
     $expectedFinder->in($testDirectory->getRealPath() . DIRECTORY_SEPARATOR . 'expected');
     $generatedFinder = new Finder();
     $generatedFinder->in($testDirectory->getRealPath() . DIRECTORY_SEPARATOR . 'generated');
     $generatedData = [];
     $this->assertEquals(count($expectedFinder), count($generatedFinder), sprintf('No same number of files for %s', $testDirectory->getRelativePathname()));
     foreach ($generatedFinder as $generatedFile) {
         $generatedData[$generatedFile->getRelativePathname()] = $generatedFile->getRealPath();
     }
     foreach ($expectedFinder as $expectedFile) {
         $this->assertArrayHasKey($expectedFile->getRelativePathname(), $generatedData, sprintf('File %s does not exist for %s', $expectedFile->getRelativePathname(), $testDirectory->getRelativePathname()));
         if ($expectedFile->isFile()) {
             $this->assertEquals(file_get_contents($expectedFile->getRealPath()), file_get_contents($generatedData[$expectedFile->getRelativePathname()]), sprintf('File %s does not have the same content for %s', $expectedFile->getRelativePathname(), $testDirectory->getRelativePathname()));
         }
     }
 }
开发者ID:jolicode,项目名称:jane,代码行数:32,代码来源:JaneBaseTest.php

示例4: processFile

 private function processFile(SplFileInfo $path)
 {
     $relativeDirName = dirname(str_replace($this->inPath, '', $path->getPathname()));
     $filenameParts = explode('/', $relativeDirName);
     $pdfDir = array_pop($filenameParts);
     $restaurant = array_pop($filenameParts);
     $outDir = $this->outPath . '/' . $relativeDirName;
     if (!is_dir($outDir)) {
         mkdir($outDir, 0777, true);
     }
     $outFilename = $outDir . '/' . str_replace('.pdf', '-%03d.png', $path->getFilename());
     $convertCommand = "gm convert -density 300 \"{$path->getPathname()}\" -resize '1280x1280>' +profile '*' +adjoin \"{$outFilename}\"";
     $this->output->writeln("Processing {$path->getPathname()}");
     // convert directory
     exec($convertCommand);
     // create csv file
     $finder = new Finder();
     $finder->files()->name('*.png')->in($outDir);
     /** @type SplFileInfo $file */
     $index = 1;
     $this->output->writeln("-- " . $finder->count() . " images");
     foreach ($finder as $file) {
         if (!isset($this->outCsv[$restaurant])) {
             $this->outCsv[$restaurant] = [];
         }
         $this->outCsv[$restaurant][] = ['restaurant' => $restaurant, 'pdf' => $path->getRelativePathname(), 'page' => $index, 'image' => $relativeDirName . '/' . $file->getFilename(), 'folder' => $relativeDirName];
         $index++;
     }
 }
开发者ID:survos,项目名称:remote,代码行数:29,代码来源:PdfToJpgCommand.php

示例5: __construct

 /**
  * Create our second level request for posting items
  *
  * @param Api         $api
  * @param SplFileInfo $file
  * @param bool        $method
  */
 public function __construct(Api $api, SplFileInfo $file, $method)
 {
     $data = $api->getResponse()->json();
     parent::__construct($api->getApiKey(), $api->getApiSecret(), $api->getHttps());
     $this->path = sprintf('%s://%s%s', $data['link']['protocol'], $data['link']['address'], $data['link']['path']);
     $this->setGet('key', $data['link']['query']['key'])->setGet('token', $data['link']['query']['token'])->setPost('file', '@' . $file->getPath() . '/' . $file->getFilename());
 }
开发者ID:lsv,项目名称:jwapi,代码行数:14,代码来源:Upload.php

示例6: handle

 /**
  * Convert a blade view into a site page.
  *
  * @param SplFileInfo $file
  *
  * @return void
  */
 public function handle(SplFileInfo $file, $viewsData)
 {
     $this->viewsData = $viewsData;
     $this->file = $file;
     $this->viewPath = $this->getViewPath();
     $this->directory = $this->getDirectoryPrettyName();
     $this->appendViewInformationToData();
     $content = $this->getFileContent();
     $this->filesystem->put(sprintf('%s/%s', $this->prepareAndGetDirectory(), ends_with($file->getFilename(), ['.blade.php', 'md']) ? 'index.html' : $file->getFilename()), $content);
     // copy images to public folder
     foreach ($file->images as $media) {
         $copyFrom = ORCA_CONTENT_DIR . "/{$file->getRelativePath()}/{$media}";
         $copyTo = "{$this->directory}/{$media}";
         if (!$this->filesystem->copy($copyFrom, $copyTo)) {
             echo "failed to copy {$media}...\n";
         }
     }
     // copy documents
     foreach ($file->documents as $media) {
         $copyFrom = ORCA_CONTENT_DIR . "/{$file->getRelativePath()}/{$media}";
         $copyTo = "{$this->directory}/{$media}";
         if (!$this->filesystem->copy($copyFrom, $copyTo)) {
             echo "failed to copy {$media}...\n";
         }
     }
 }
开发者ID:tao,项目名称:orca,代码行数:33,代码来源:BlogPostHandler.php

示例7: modify

 /**
  * @see ContentModifierInterface::modify()
  */
 public function modify(SplFileInfo $generatedFile, array $data, Inflector $inflector, SplFileInfo $templateFile)
 {
     $options = $this->resolver->resolve($data);
     // retrieve target location
     $targetConfigFilepath = $this->resolveTargetFilePath($options['target'], $generatedFile->getPath());
     $emBundleDefinition = sprintf('
                 %s:
                     type: yml
                     dir: %s
                     prefix: %s
                     alias: %s
                     ', $options['bundle'], $options['relative_schema_directory'], $options['prefix'], $options['alias']);
     $configsFile = new SplFileInfo($targetConfigFilepath, '', '');
     $configsContent = $configsFile->getContents();
     // are configs not already registered ?
     if (strpos($configsContent, trim($emBundleDefinition)) !== false) {
         $this->logger->debug(sprintf('Config file "%s" is already registered into "%s". Abording.', $generatedFile->getFilename(), $targetConfigFilepath));
         return $generatedFile->getContents();
     }
     $this->filesystem->dumpFile($configsFile->getPathname(), str_replace(sprintf('
     entity_managers:
         %s:
             mappings:', $options['em']), sprintf('
     entity_managers:
         %s:
             mappings:%s', $options['em'], $emBundleDefinition), $configsContent));
     $this->logger->info(sprintf('file updated : %s', $configsFile->getPathname()));
     return $generatedFile->getContents();
 }
开发者ID:henres,项目名称:MajoraGeneratorBundle,代码行数:32,代码来源:RegisterDoctrineEmModifier.php

示例8: put

 public function put($src, $dest)
 {
     if (false === file_exists($src)) {
         throw new \InvalidArgumentException(sprintf('Resource \'%s\' does not exist', $src));
     }
     if (is_file($src) && is_dir($dest)) {
         $dest = $dest . DIRECTORY_SEPARATOR . basename($src);
     }
     if (is_file($src)) {
         $file = new \SplFileInfo($src);
         $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_PUT, new TransporterEvent($this, array('dest' => $dest, 'src' => $file->getPathname())));
         $pwd = dirname($dest);
         if (!is_dir($pwd)) {
             $this->mkdir($pwd);
         }
         copy($file->getPathname(), $dest);
     } else {
         if (!$this->exists($dest)) {
             $this->mkdir($dest);
         }
         $finder = new Finder();
         $test = $finder->in($src)->depth('== 0');
         foreach ($test as $file) {
             $this->put(rtrim($src, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file->getFilename(), rtrim($dest, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file->getFilename());
         }
     }
 }
开发者ID:webcreate,项目名称:conveyor,代码行数:27,代码来源:FileTransporter.php

示例9: readFile

 public static function readFile($path)
 {
     $file = new SplFileInfo($path, '', '');
     if (!$file->isFile()) {
         throw new Exception('Invalid file. Fail to get file ' . $path);
     }
     return $file;
 }
开发者ID:learnosity,项目名称:learnosity-qti,代码行数:8,代码来源:FileSystemUtil.php

示例10: createImageObject

 /**
  * @param SplFileInfo $file
  * @return StdClass
  */
 protected function createImageObject(SplFileInfo $file)
 {
     $obj = new StdClass();
     $path = $file->getRelativePathname();
     $obj->url = route('imagecache', ['original', $path]);
     $obj->thumbnail = route('imagecache', ['small', $path]);
     return $obj;
 }
开发者ID:procoders,项目名称:admin,代码行数:12,代码来源:ImagesController.php

示例11: __construct

 /**
  * __construct 
  */
 protected function __construct(SplFileInfo $file, $relativePath = null)
 {
     $this->title = Content::filename_to_title($file->getFilename());
     $this->slug = Content::str_to_slug($file->getFilename());
     $relativePath = !is_null($relativePath) && !empty($relativePath) ? $relativePath : $file->getRelativePath();
     $this->path = $relativePath . (ends_with($relativePath, '/') ? '' : '/') . $this->slug;
     $this->file = $file;
 }
开发者ID:avvertix,项目名称:pronto-framework,代码行数:11,代码来源:SectionItem.php

示例12: getConfigurationNesting

 /**
  * Get the configuration file nesting path.
  *
  * @param  \Symfony\Component\Finder\SplFileInfo  $file
  * @return string
  */
 private function getConfigurationNesting(SplFileInfo $file)
 {
     $directory = dirname($file->getPathname());
     if ($tree = trim(str_replace(config_path(), '', $directory), DIRECTORY_SEPARATOR)) {
         $tree = str_replace(DIRECTORY_SEPARATOR, '.', $tree) . '.';
     }
     return $tree;
 }
开发者ID:consolle,项目名称:framework,代码行数:14,代码来源:LoadConfiguration.php

示例13: verifyFrontMatterSeparatorExists

 /**
  * @param SplFileInfo $file
  *
  * @return void
  *
  * @throws InvalidContentFile
  */
 protected function verifyFrontMatterSeparatorExists(SplFileInfo $file)
 {
     $content = $file->getContents();
     $fileName = $file->getFilename();
     if (false === strpos($content, FrontMatter::SEPARATOR)) {
         throw new InvalidContentFile("Missing '---' deliminator in " . $fileName);
     }
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:15,代码来源:Validator.php

示例14: getFileContents

 /**
  * @param SplFileInfo $file
  *
  * @return string
  */
 private function getFileContents(SplFileInfo $file)
 {
     $content = $file->getContents();
     if ($file->getExtension() === 'js' && substr($content, -1) !== ';') {
         $content .= ';';
     }
     return $content;
 }
开发者ID:bldr-io,项目名称:frontend-block,代码行数:13,代码来源:ConcatTask.php

示例15: getConfigurationNesting

 /**
  * @param \Symfony\Component\Finder\SplFileInfo $file
  * @param string                                $configPath
  *
  * @return string
  */
 protected function getConfigurationNesting(SplFileInfo $file, $configPath)
 {
     $directory = dirname($file->getRealPath());
     if ($tree = trim(str_replace($configPath, '', $directory), DIRECTORY_SEPARATOR)) {
         $tree = str_replace(DIRECTORY_SEPARATOR, '.', $tree) . '.';
     }
     return $tree;
 }
开发者ID:notadd,项目名称:framework,代码行数:14,代码来源:LoadConfiguration.php


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