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


PHP SplFileInfo::getPath方法代码示例

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


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

示例1: detectSystem

 /**
  * try to verify a search result
  *
  * @param   SplFileInfo  $file  file to examine
  *
  * @return  bool|System
  */
 public function detectSystem(SplFileInfo $file)
 {
     if ($file->getFilename() == "system.info" && stripos($file->getContents(), 'project = "drupal"') !== false) {
         $path = new \SplFileInfo(dirname(dirname($file->getPath())));
         return new System($this->getName(), $path);
     }
     if ($file->getFilename() == "system.info.yml" && stripos($file->getContents(), "project: 'drupal'") !== false) {
         $path = new \SplFileInfo(dirname(dirname(dirname($file->getPath()))));
         return new System($this->getName(), $path);
     }
     return false;
 }
开发者ID:antondollmaier,项目名称:cmsscanner,代码行数:19,代码来源:DrupalAdapter.php

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

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

示例4: getConfigurationNesting

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

示例5: extractRegisterInformation

 /**
  * @param SplFileInfo $file
  *
  * @return array
  */
 public function extractRegisterInformation(SplFileInfo $file)
 {
     $content = Yaml::parse($file->getContents());
     $result = array('namespace' => $content['namespace'], 'source_dir' => rtrim($file->getPathInfo()->getRealPath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($content['source_dir'], DIRECTORY_SEPARATOR));
     $name = array();
     preg_match('#(?P<name>[a-z\\-]*)/?$#i', $file->getPath(), $name);
     $key = $name['name'];
     $this->moduleList[$key] = $result;
     return $result;
 }
开发者ID:christophe-chausseray,项目名称:autoregister-classmap-plugin,代码行数:15,代码来源:RegisterFileParser.php

示例6: detectSystem

 /**
  * verify a search result by making sure that the file has the correct name and $wp_version is in there
  *
  * @param   SplFileInfo  $file  file to examine
  *
  * @return  bool|System
  */
 public function detectSystem(SplFileInfo $file)
 {
     if ($file->getFilename() != "version.php") {
         return false;
     }
     if (stripos($file->getContents(), '$wp_version =') === false) {
         return false;
     }
     $path = new \SplFileInfo(dirname($file->getPath()));
     return new System($this->getName(), $path);
 }
开发者ID:antondollmaier,项目名称:cmsscanner,代码行数:18,代码来源:WordpressAdapter.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
     $targetServicesFilepath = $this->resolveTargetFilePath($options['target'], $generatedFile->getPath());
     // build content
     $import = sprintf('<import resource="%s" />', $inflector->translate($options['resource']));
     $servicesFile = new SplFileInfo($targetServicesFilepath, '', '');
     $servicesContent = $servicesFile->getContents();
     // are services not already registered ?
     if (strpos($servicesContent, $import) !== false) {
         $this->logger->debug(sprintf('Service file "%s" is already registered into "%s". Abording.', $generatedFile->getFilename(), $targetServicesFilepath));
         return $generatedFile->getContents();
     }
     $this->filesystem->dumpFile($servicesFile->getRealpath(), str_replace('    </imports>', sprintf("        %s\n    </imports>", $import), $servicesContent));
     $this->logger->info(sprintf('file updated : %s', $servicesFile->getRealpath()));
     return $generatedFile->getContents();
 }
开发者ID:henres,项目名称:MajoraGeneratorBundle,代码行数:21,代码来源:ImportXmlServicesModifier.php

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

示例9: modify

    /**
     * @see ContentModifierInterface::modify()
     */
    public function modify(SplFileInfo $generatedFile, array $data, Inflector $inflector, SplFileInfo $templateFile)
    {
        $options = $this->resolver->resolve($data);
        // retrieve target location
        $targetRoutingFilepath = $this->resolveTargetFilePath($options['target'], $generatedFile->getPath());
        // build content
        $routing = sprintf('
%s:
    resource: "%s"
    %s', $inflector->translate($options['route']), $inflector->translate($options['resource']), is_null($options['prefix']) ? '' : sprintf("prefix: %s\n", $inflector->translate($options['prefix'])));
        $routingFile = new SplFileInfo($targetRoutingFilepath, '', '');
        $routingContent = $routingFile->getContents();
        // is routing not already registered ?
        if (strpos($routingContent, trim($routing)) !== false) {
            $this->logger->debug(sprintf('Routing file "%s" is already registered into "%s". Abording.', $generatedFile->getFilename(), $targetRoutingFilepath));
            return $generatedFile->getContents();
        }
        $this->filesystem->dumpFile($routingFile->getRealpath(), sprintf('%s%s', $routingContent, $routing));
        $this->logger->info(sprintf('file updated : %s', $routingFile->getRealpath()));
        return $generatedFile->getContents();
    }
开发者ID:henres,项目名称:MajoraGeneratorBundle,代码行数:24,代码来源:UpdateRoutingModifier.php

示例10: detectSystem

 /**
  * try to verify a search result and work around some well known false positives
  *
  * @param   SplFileInfo  $file  file to examine
  *
  * @return  bool|System
  */
 public function detectSystem(SplFileInfo $file)
 {
     if ($file->getFilename() != "configuration.php") {
         return false;
     }
     if (stripos($file->getContents(), "JConfig") === false) {
         return false;
     }
     // False positive "Akeeba Backup Installer"
     if (stripos($file->getContents(), "class ABIConfiguration") !== false) {
         return false;
     }
     // False positive mock file in unit test folder
     if (stripos($file->getContents(), "Joomla.UnitTest") !== false) {
         return false;
     }
     // False positive mock file in unit test folder
     if (stripos($file->getContents(), "Joomla\\Framework\\Test") !== false) {
         return false;
     }
     $path = new \SplFileInfo($file->getPath());
     // Return result if working
     return new System($this->getName(), $path);
 }
开发者ID:antondollmaier,项目名称:cmsscanner,代码行数:31,代码来源:JoomlaAdapter.php

示例11: applyVariables

 /**
  * @param string $rawConfig
  * @param string $magentoRootFolder
  * @param SplFileInfo|null $file [optional]
  *
  * @return string
  */
 protected function applyVariables($rawConfig, $magentoRootFolder, SplFileInfo $file = null)
 {
     $replace = array('%module%' => $file ? $file->getPath() : '', '%root%' => $magentoRootFolder);
     return str_replace(array_keys($replace), $replace, $rawConfig);
 }
开发者ID:ktomk,项目名称:n98-magerun2,代码行数:12,代码来源:ConfigurationLoader.php

示例12: saveFileAction

 /**
  * @Route("/file_manager/new-file/save", name="spliced_cms_admin_file_manager_save_file")
  * @Template("SplicedCmsBundle:Admin/FileManagement:new_file.html.twig")
  */
 public function saveFileAction()
 {
     $view = $this->getViewContext();
     $fileForm = $this->createForm(new FileFormType(null), array());
     if ($fileForm->submit($this->get('request')) && $fileForm->isValid()) {
         $file = $fileForm->getData();
         $fileInfo = new \SplFileInfo($this->dir->getRealPath() . '/' . $file['fileName']);
         $relativePath = str_replace($this->baseDir->getRealPath(), '', $fileInfo->getPath());
         $wrote = file_put_contents($fileInfo->getPath() . '/' . $fileInfo->getFilename(), $file['content']);
         if (false === $wrote) {
             $this->get('session')->getFlashBag()->add('error', 'There was an error saving the file. Permission Denied');
         } else {
             return $this->redirect($this->generateUrl('spliced_cms_admin_file_manager_edit_file', array('dir' => $relativePath, 'file' => $fileInfo->getFilename())));
         }
     } else {
         $this->get('session')->getFlashBag()->add('error', 'There was an error validating your submission');
     }
     return array_merge($view, array('fileForm' => $fileForm->createView()));
 }
开发者ID:splicedmedia,项目名称:cms-bundle,代码行数:23,代码来源:FileManagementController.php

示例13: exists

 /**
  * @return bool
  */
 public function exists()
 {
     return is_file($this->file->getPath());
 }
开发者ID:eva,项目名称:eva,代码行数:7,代码来源:File.php

示例14: parseScenario

 /**
  * @param string      $scenario
  * @param SplFileInfo $fileInfo
  *
  * @todo make it event driven
  *
  * @return string
  */
 public function parseScenario($scenario, $fileInfo)
 {
     $feature = '';
     list($title, $body) = explode(PHP_EOL, $scenario, 2);
     $feature .= '### ' . $title . PHP_EOL . PHP_EOL . $body . PHP_EOL . PHP_EOL;
     $path = $fileInfo->getPath() . '/' . $fileInfo->getBasename('.feature');
     if (is_dir($path)) {
         $targetFile = $path . '/' . $this->sanitizeFileName($title) . '.md';
         if (is_readable($targetFile)) {
             $feature .= file_get_contents($targetFile) . PHP_EOL . PHP_EOL;
         }
     }
     return $feature;
 }
开发者ID:sourcerer-mike,项目名称:mdoc,代码行数:22,代码来源:Merge.php

示例15: getRelativePath

 /**
  * Make the path relative to a given path.
  *
  * If path = src/Resources/images
  * Pathname = src/Resources/images/subdir/image.png
  * Relativepath = subdir/image.png
  *
  * @param $path
  * @param SplFileInfo $file
  * @return mixed
  */
 private function getRelativePath($path, SplFileInfo $file)
 {
     return str_replace($path, '', $file->getPath());
 }
开发者ID:ftdysa,项目名称:website,代码行数:15,代码来源:ResizeImagesCommand.php


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