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


PHP SplFileInfo::getPathname方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: getClassNameParts

 /**
  * @param \Symfony\Component\Finder\SplFileInfo $fileInfo
  *
  * @throws \Exception
  *
  * @return array
  */
 private function getClassNameParts(SplFileInfo $fileInfo)
 {
     $pathParts = explode(DIRECTORY_SEPARATOR, $fileInfo->getPathname());
     $sourceDirectoryPosition = array_search('src', $pathParts);
     if ($sourceDirectoryPosition) {
         return array_slice($pathParts, $sourceDirectoryPosition + 1);
     }
     $testsDirectoryPosition = array_search('tests', $pathParts);
     if ($testsDirectoryPosition) {
         return array_slice($pathParts, $testsDirectoryPosition + 2);
     }
     throw new \Exception(sprintf('Could not extract class name parts from file "%s".', $fileInfo->getPathname()));
 }
开发者ID:spryker,项目名称:Development,代码行数:20,代码来源:FileInfoExtractor.php

示例5: updateComposerJsonFile

 /**
  * @param \Symfony\Component\Finder\SplFileInfo $composerJsonFile
  *
  * @return void
  */
 protected function updateComposerJsonFile(SplFileInfo $composerJsonFile)
 {
     exec('./composer.phar validate ' . $composerJsonFile->getPathname(), $output, $return);
     if ($return !== 0) {
         throw new \RuntimeException('Invalid composer file ' . $composerJsonFile->getPathname() . ': ' . print_r($output, true));
     }
     $composerJson = json_decode($composerJsonFile->getContents(), true);
     $composerJson = $this->updater->update($composerJson, $composerJsonFile);
     $composerJson = $this->clean($composerJson);
     $composerJson = json_encode($composerJson, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
     $composerJson = preg_replace(self::REPLACE_4_WITH_2_SPACES, '$1', $composerJson) . PHP_EOL;
     file_put_contents($composerJsonFile->getPathname(), $composerJson);
 }
开发者ID:spryker,项目名称:Development,代码行数:18,代码来源:ComposerJsonUpdater.php

示例6: __construct

 /**
  * Create sprite image data holder
  * @param string $path
  * @param SplFileInfo $fileInfo
  */
 public function __construct($path, SplFileInfo $fileInfo)
 {
     $this->basePath = $path;
     $this->info = $fileInfo;
     // Assign fileinfo variables
     $this->path = $this->info->getPathname();
     $this->size = $this->info->getSize();
     // Assign image data
     $info = getimagesize($this->path);
     if (!is_array($info)) {
         throw new UnexpectedValueException("The image '{$this->path}' is not a correct image format.");
     }
     $this->hash = sha1(file_get_contents($this->getFullPath()));
     $this->width = (int) $info[0];
     $this->height = (int) $info[1];
     $this->mime = $info['mime'];
     $this->type = explode('/', $this->mime)[1];
     // Assign css name
     $ext = $this->info->getExtension();
     // Replace path parts with `-`
     $name = str_replace(['/', '\\', '_'], '-', $this->info->getRelativePathname());
     // Remove leading `-`
     $name = preg_replace('~^-*~', '', $name);
     // Remove double dashes
     $name = preg_replace('~-+~', '-', $name);
     // Remove file extension
     $name = preg_replace("~\\.{$ext}\$~", '', $name);
     // Replace dots with -
     $name = preg_replace('~\\.~', '-', $name);
     $this->name = $name;
 }
开发者ID:maslosoft,项目名称:sprite,代码行数:36,代码来源:SpriteImage.php

示例7: __sleep

 /**
  * Because SplFileInfo can't be serialized, we need to replace it with data that can be recovered when we serialize
  * this object again.
  *
  * @return array
  */
 public function __sleep()
 {
     $fileInfo = ['file' => $this->file->getPathname(), 'relativePath' => $this->file->getRelativePath(), 'relativePathname' => $this->file->getRelativePathname()];
     $classVars = get_object_vars($this);
     $this->file = $fileInfo;
     return array_keys($classVars);
 }
开发者ID:synga-nl,项目名称:inheritance-finder,代码行数:13,代码来源:PhpClass.php

示例8: 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

示例9: updateAutoloadForTests

 /**
  * @param array $composerJson
  * @param \Symfony\Component\Finder\SplFileInfo $composerJsonFile
  *
  * @return array
  */
 protected function updateAutoloadForTests(array $composerJson, SplFileInfo $composerJsonFile)
 {
     $testDirectoryKeys = $this->buildTestDirectoryKeys();
     $bundlePath = dirname($composerJsonFile->getPathname());
     foreach ($testDirectoryKeys as $testDirectoryKey) {
         $composerJson = $this->updateAutoload($composerJson, $testDirectoryKey, $bundlePath);
     }
     return $composerJson;
 }
开发者ID:spryker,项目名称:Development,代码行数:15,代码来源:AutoloadUpdater.php

示例10:

 function it_searches_for_files(FinderFactoryInterface $finderFactory, Finder $finder, SplFileInfo $firstSplFileInfo, SplFileInfo $secondSplFileInfo)
 {
     $finderFactory->create()->willReturn($finder);
     $finder->name('readme.md')->shouldBeCalled()->willReturn($finder);
     $finder->in(['/search/path/'])->shouldBeCalled()->willReturn($finder);
     $finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder);
     $finder->files()->shouldBeCalled()->willReturn($finder);
     $finder->getIterator()->willReturn(new \ArrayIterator([$firstSplFileInfo->getWrappedObject(), $secondSplFileInfo->getWrappedObject()]));
     $finder->count()->willReturn(2);
     $firstSplFileInfo->getPathname()->willReturn('/search/path/nested1/readme.md');
     $secondSplFileInfo->getPathname()->willReturn('/search/path/nested2/readme.md');
     $this->locateFilesNamed('readme.md')->shouldReturn(['/search/path/nested1/readme.md', '/search/path/nested2/readme.md']);
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:13,代码来源:RecursiveFileLocatorSpec.php

示例11: updateContent

 public function updateContent(SplFileInfo $fileInfo)
 {
     $pathname = $this->getAttribute('pathname');
     $process = new Process("diff {$pathname} {$fileInfo->getPathname()}", storage_path('pigeon'));
     $process->run();
     $output = $process->getOutput();
     preg_match_all('/^>\\s*(.*)/mix', $output, $matches);
     if ($matches) {
         $newText = implode("\n", $matches[1]);
         app('files')->append(storage_path('pigeon') . '/' . $pathname, "\n" . $newText);
         $this->setAttribute('modified_at', $fileInfo->getMTime());
     }
 }
开发者ID:vansanblch,项目名称:pigeon-hunt,代码行数:13,代码来源:Files.php

示例12: modify

 /**
  * @see ContentModifierInterface::modify()
  */
 public function modify(SplFileInfo $generatedFile, array $data, Inflector $inflector, SplFileInfo $templateFile)
 {
     $options = $this->resolver->resolve($data);
     $fileContent = $generatedFile->getContents();
     // current file is a bundle ?
     $isInBundle = preg_match(sprintf('/namespace (.*%s.*Bundle);/', $inflector->translate('MajoraNamespace')), $fileContent, $inBundleMatches);
     $isABundle = preg_match(sprintf('/class (([\\w]*)%s[\\w]*Bundle) extends [\\w]*Bundle/', $inflector->translate('MajoraNamespace')), $fileContent, $isBundleMatches);
     if (!$isInBundle || !$isABundle) {
         $this->logger->notice(sprintf('Try to register "%s" file into Kernel which isnt a bundle. Abording.', $generatedFile->getFilename()));
         return $fileContent;
     }
     $bundleInclusion = sprintf('new %s\\%s(),', $inBundleMatches[1], $isBundleMatches[1]);
     $kernelFile = new SplFileInfo(sprintf('%s/%s', $this->kernelDir, $options['kernel_filename']), '', '');
     $kernelContent = $kernelFile->getContents();
     // is bundle not already registered ?
     if (strpos($kernelContent, $bundleInclusion) !== false) {
         $this->logger->debug(sprintf('Bundle "%s" is already registered. Abording.', $generatedFile->getFilename()));
         return $fileContent;
     }
     $this->filesystem->dumpFile($kernelFile->getPathname(), preg_replace('/(Bundle\\(\\)\\,)(\\n[\\s]+\\);)/', sprintf("\$1\n            %s\$2", $bundleInclusion), $kernelContent));
     $this->logger->info(sprintf('file updated : %s', $kernelFile->getPathname()));
     return $fileContent;
 }
开发者ID:henres,项目名称:MajoraGeneratorBundle,代码行数:26,代码来源:RegisterBundleModifier.php

示例13: import

 public function import(\Symfony\Component\Finder\SplFileInfo $file, $force = false)
 {
     $this->validateLoaders($this->loaders);
     $filename = $file->getFilename();
     list($domain, $locale, $extension) = explode('.', $filename);
     if (!isset($this->loaders[$extension]) || !$this->loaders[$extension] instanceof \Symfony\Component\Translation\Loader\LoaderInterface) {
         throw new \Exception(sprintf('Requested loader for extension .%s isnt set', $extension));
     }
     $loader = $this->loaders[$extension];
     $messageCatalogue = $loader->load($file->getPathname(), $locale, $domain);
     $importedTranslations = 0;
     foreach ($messageCatalogue->all($domain) as $keyword => $text) {
         if ($this->importSingleTranslation($keyword, $text, $locale, $filename, $domain, $force)) {
             $importedTranslations++;
         }
     }
     return $importedTranslations;
 }
开发者ID:VickyDeschrijver,项目名称:KunstmaanBundlesCMS,代码行数:18,代码来源:Importer.php

示例14: addDependencies

 /**
  * @param \Symfony\Component\Finder\SplFileInfo $fileInfo
  *
  * @return void
  */
 public function addDependencies(SplFileInfo $fileInfo)
 {
     $content = $fileInfo->getContents();
     $_SERVER['argv'] = [];
     if (!defined('STDIN')) {
         define('STDIN', fopen(__FILE__, 'r'));
     }
     $file = new \PHP_CodeSniffer_File($fileInfo->getPathname(), [], [], new \PHP_CodeSniffer());
     $file->start($content);
     $tokens = $file->getTokens();
     $pointer = 0;
     $classNames = [];
     while ($foundPosition = $file->findNext([T_NEW, T_USE, T_DOUBLE_COLON], $pointer)) {
         $pointer = $foundPosition + 1;
         $currentToken = $tokens[$foundPosition];
         if ($currentToken['type'] === 'T_NEW' || $currentToken['type'] === 'T_USE') {
             $pointer = $foundPosition + 2;
             $endOfNew = $file->findNext([T_SEMICOLON, T_OPEN_PARENTHESIS, T_WHITESPACE, T_DOUBLE_COLON], $pointer);
             $classNameParts = array_slice($tokens, $pointer, $endOfNew - $foundPosition - 2);
             $classNames[] = $this->buildClassName($classNameParts);
         }
         if ($currentToken['type'] === 'T_DOUBLE_COLON') {
             $pointer = $foundPosition + 1;
             $startOf = $file->findPrevious([T_OPEN_PARENTHESIS, T_WHITESPACE, T_OPEN_SQUARE_BRACKET], $foundPosition - 1) + 1;
             $classNameParts = array_slice($tokens, $startOf, $foundPosition - $startOf);
             $classNames[] = $this->buildClassName($classNameParts);
         }
     }
     $classNames = array_unique($classNames);
     foreach ($classNames as $className) {
         $className = ltrim($className, '\\');
         if (strpos($className, '_') === false && strpos($className, '\\') === false) {
             continue;
         }
         if (strpos($className, 'Spryker') !== false || strpos($className, 'Generated') !== false || strpos($className, 'Orm') !== false || strpos($className, 'static') !== false || strpos($className, 'self') !== false) {
             continue;
         }
         $dependencyInformation[DependencyTree::META_FOREIGN_LAYER] = 'external';
         $dependencyInformation[DependencyTree::META_FOREIGN_CLASS_NAME] = $className;
         $dependencyInformation[DependencyTree::META_FOREIGN_IS_EXTERNAL] = true;
         $this->addDependency($fileInfo, 'external', $dependencyInformation);
     }
     $this->cleanAutoloader();
 }
开发者ID:spryker,项目名称:Development,代码行数:49,代码来源:ExternalDependency.php

示例15: import

 /**
  * Impoort the given file and return the number of inserted translations.
  *
  * @param \Symfony\Component\Finder\SplFileInfo $file
  * @param boolean                               $forceUpdate  force update of the translations
  * @return int
  */
 public function import(\Symfony\Component\Finder\SplFileInfo $file, $forceUpdate = false)
 {
     $imported = 0;
     list($domain, $locale, $extention) = explode('.', $file->getFilename());
     if (isset($this->loaders[$extention])) {
         $messageCatalogue = $this->loaders[$extention]->load($file->getPathname(), $locale, $domain);
         $translationFile = $this->fileManager->getFor($file->getFilename(), $file->getPath());
         foreach ($messageCatalogue->all($domain) as $key => $content) {
             // skip empty translation values
             if (!isset($content)) {
                 continue;
             }
             $transUnit = $this->storage->getTransUnitByKeyAndDomain($key, $domain);
             if (!$transUnit instanceof TransUnitInterface) {
                 $transUnit = $this->transUnitManager->create($key, $domain);
             }
             $translation = $this->transUnitManager->addTranslation($transUnit, $locale, $content, $translationFile);
             if ($translation instanceof TranslationInterface) {
                 $imported++;
             } else {
                 if ($forceUpdate) {
                     $translation = $this->transUnitManager->updateTranslation($transUnit, $locale, $content);
                     $imported++;
                 }
             }
             // convert MongoTimestamp objects to time to don't get an error in:
             // Doctrine\ODM\MongoDB\Mapping\Types\TimestampType::convertToDatabaseValue()
             if ($transUnit instanceof TransUnitDocument) {
                 $transUnit->convertMongoTimestamp();
             }
         }
         $this->storage->flush();
         // clear only Lexik entities
         foreach (array('file', 'trans_unit', 'translation') as $name) {
             $this->storage->clear($this->storage->getModelClass($name));
         }
     } else {
         throw new \RuntimeException(sprintf('No load found for "%s" format.', $extention));
     }
     return $imported;
 }
开发者ID:StuartApp,项目名称:LexikTranslationBundle,代码行数:48,代码来源:FileImporter.php


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