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


PHP SplFileInfo::getRelativePathname方法代码示例

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


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

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

示例2: _getAbsoluteFilePathToCompareAgainst

 protected function _getAbsoluteFilePathToCompareAgainst()
 {
     // todokj The 'enterprise' needs to be determined dynamically
     $design = \Mage::getSingleton('core/design_package');
     $filename = $design->getFilename($this->_file->getRelativePathname(), array('_area' => 'frontend', '_package' => $this->_getPackageToCompareAgainst(), '_theme' => $this->_getPackageThemeToCompareAgainst(), '_type' => $this->_getType()));
     return $filename;
 }
开发者ID:adamlevenson,项目名称:magerun-addons,代码行数:7,代码来源:AbstractThemeComparisonItem.php

示例3: processFile

 public function processFile(SplFileInfo $file, $folder = '', $type = Document::TYPE_UNKNOWN)
 {
     $internalPath = trim($folder . '/' . $file->getRelativePathname(), '/');
     $document = new Document($file, $internalPath, $type);
     $event = new CarewEvent($document);
     try {
         return $this->eventDispatcher->dispatch(Events::DOCUMENT_HEADER, $event)->getSubject();
     } catch (\Exception $e) {
         throw new \LogicException(sprintf('Could not process "%s": "%s".', $file->getRelativePathname(), $e->getMessage()), 0, $e);
     }
 }
开发者ID:carew,项目名称:carew,代码行数:11,代码来源:Processor.php

示例4: upload

 public function upload(File $file, $metaData)
 {
     try {
         if ($metaData['Content-Encoding']) {
             $this->client->putObject(array('Bucket' => $this->name, 'Key' => $file->getRelativePathname(), 'SourceFile' => $file->getRealpath(), 'ACL' => CannedAcl::PUBLIC_READ, 'ContentEncoding' => $metaData['Content-Encoding']));
         } else {
             $this->client->putObject(array('Bucket' => $this->name, 'Key' => $file->getRelativePathname(), 'SourceFile' => $file->getRealpath(), 'ACL' => CannedAcl::PUBLIC_READ));
         }
     } catch (InstanceProfileCredentialsException $e) {
         throw new InvalidAccessKeyIdException("The AWS Access Key Id you provided does not exist in our records.");
     }
 }
开发者ID:arvinkx,项目名称:git-s3,代码行数:12,代码来源:Bucket.php

示例5: __construct

 /**
  * Constructor
  *
  * @param Analyzer            $analyzer   Analyzer
  * @param DataSourceInterface $dataSource Data Source
  * @param SplFileInfo         $file       File
  * @param bool                $isRaw      Should be treated as raw
  * @param bool                $hasChanged Has the file changed?
  */
 public function __construct(Analyzer $analyzer, DataSourceInterface $dataSource, SplFileInfo $file, $isRaw, $hasChanged = false)
 {
     $this->analyzer = $analyzer;
     $this->sourceId = 'FileSource:' . $dataSource->dataSourceId() . ':' . $file->getRelativePathname();
     $this->relativePathname = $file->getRelativePathname();
     $this->filename = $file->getFilename();
     $this->file = $file;
     $this->isRaw = $isRaw;
     $this->hasChanged = $hasChanged;
     $internetMediaTypeFactory = $this->analyzer->getInternetMediaTypeFactory();
     $this->applicationXmlType = $internetMediaTypeFactory->createApplicationXml();
     $this->init();
 }
开发者ID:georgjaehnig,项目名称:sculpin,代码行数:22,代码来源:FileSource.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: 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

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

示例9: uploadFile

 private function uploadFile(File $file)
 {
     if ($file->getFilename() == 'config.yml') {
         return;
     }
     $this->output->writeln('Uploading ' . $file->getRelativePathname());
     $this->bucket->upload($file);
 }
开发者ID:schickling,项目名称:git-s3,代码行数:8,代码来源:DeployCommand.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: uploadFile

 private function uploadFile(File $file)
 {
     // Check if isCompressed was passed and if
     // the file is a JS or CSS file add the
     // correct content encoding
     $ext = pathinfo($file->getRelativePathname(), PATHINFO_EXTENSION);
     $metaData = array();
     if (($ext == "js" || $ext == "css" || $ext == 'json') && $this->isCompressed) {
         $metaData['Content-Encoding'] = 'gzip';
         if ($ext == "js") {
             $metaData['Content-Type'] = 'text/javascript';
         } else {
             $metaData['Content-Type'] = 'text/css';
         }
     }
     $this->output->writeln('Uploading ' . $file->getRelativePathname());
     $this->bucket->upload($file, $metaData);
 }
开发者ID:arvinkx,项目名称:git-s3,代码行数:18,代码来源:DeployCommand.php

示例12: prepareFile

 protected function prepareFile(SplFileInfo $file)
 {
     $filePath = $file->getRelativePathname();
     if ($file->isDir()) {
         $this->newConfig['folders'][] = $filePath;
         return;
     }
     $fileContents = file_get_contents($file->getRealPath());
     $this->newConfig['files'][$filePath] = $fileContents;
 }
开发者ID:revati,项目名称:packager,代码行数:10,代码来源:MakeTemplateConfigCommand.php

示例13:

 function it_should_filter_by_not_path(SplFileInfo $file1, SplFileInfo $file2)
 {
     $file1->getRelativePathname()->willReturn('path1/file.php');
     $file2->getRelativePathname()->willReturn('path2/file.png');
     $result = $this->notPath('path2');
     $result->shouldBeAnInstanceOf('GrumPHP\\Collection\\FilesCollection');
     $result->count()->shouldBe(1);
     $files = $result->toArray();
     $files[0]->shouldBe($file1);
 }
开发者ID:spinx,项目名称:grumphp,代码行数:10,代码来源:FilesCollectionSpec.php

示例14: loadContext

 /**
  * loadContext
  *
  * @return array
  */
 private function loadContext()
 {
     $this->files = new Finder();
     $this->baseDir = new SplFileInfo($this->get('spliced_cms.site_manager')->getCurrentAdminSite()->getRootDir(), '/', '/');
     if ($this->get('request')->query->has('dir')) {
         $path = $this->baseDir->getRealPath() . '/' . $this->get('request')->query->get('dir');
         $relativePath = preg_replace('/\\/{2,}/', '/', str_replace($this->baseDir->getRealPath(), '', $path));
         $this->dir = new SplFileInfo($path, $relativePath, $relativePath);
     } else {
         $this->dir = $this->baseDir;
     }
     $this->files->followLinks()->depth(0)->in($this->dir->getRealPath());
     $this->file = null;
     if ($this->get('request')->query->has('file') && $this->get('request')->query->get('file')) {
         $this->file = new SplFileInfo($this->dir->getRealPath() . '/' . $this->get('request')->query->get('file'), $this->dir->getRelativePath() . '/' . $this->get('request')->query->get('file'), $this->dir->getRelativePathname());
     }
     $this->loaded = true;
     return $this;
 }
开发者ID:splicedmedia,项目名称:cms-bundle,代码行数:24,代码来源:FileManagementController.php

示例15: getClassIdentifier

 /**
  * @param SplFileInfo   $file
  * @param string        $classPrefix
  * @param string        $group
  * @return string
  */
 protected function getClassIdentifier(SplFileInfo $file, $classPrefix, $group = '')
 {
     $path = str_replace('.php', '', $file->getRelativePathname());
     $path = str_replace('\\', '/', $path);
     $parts = explode('/', $path);
     $parts = array_map('lcfirst', $parts);
     if ($path == 'Data' && $group == 'helpers') {
         array_pop($parts);
     }
     return rtrim($classPrefix . '/' . implode('_', $parts), '/');
 }
开发者ID:iMi-digital,项目名称:imi-conrun,代码行数:17,代码来源:MetaCommand.php


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