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


PHP SplFileInfo::getContents方法代码示例

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


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

示例1: read

 /**
  * @return string
  */
 public function read()
 {
     if ($this->contents) {
         return $this->contents;
     }
     return $this->contents = $this->file->getContents();
 }
开发者ID:eva,项目名称:eva,代码行数:10,代码来源:File.php

示例2: getFileContent

 /**
  * Get the content of the file after rendering.
  *
  * @param SplFileInfo $file
  *
  * @return string
  */
 protected function getFileContent()
 {
     if (ends_with($this->file->getFilename(), '.blade.php')) {
         return $this->renderBlade();
     } elseif (ends_with($this->file->getFilename(), '.md')) {
         return $this->renderMarkdown();
     }
     return $this->file->getContents();
 }
开发者ID:tao,项目名称:orca,代码行数:16,代码来源:BaseHandler.php

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

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

示例5: parseFeature

 /**
  * @param SplFileInfo $fileInfo
  *
  * @todo make it event driven
  *
  * @return mixed|string
  *
  */
 protected function parseFeature($fileInfo)
 {
     $feature = $fileInfo->getContents();
     $scenarios = explode('Szenario:', $feature);
     $feature = array_shift($scenarios);
     $lines = explode(PHP_EOL, $feature);
     if (0 === strpos($feature, '#')) {
         array_shift($lines);
     }
     $title = array_shift($lines);
     $title = str_replace('Funktionalität: ', '## ', $title);
     $userStory = trim(implode(PHP_EOL, $lines));
     $userStory = preg_replace('/\\n[\\s]*/', "\n", $userStory);
     $imageFile = $fileInfo->getPath() . '/' . $fileInfo->getBasename('.feature') . '.png';
     $output = $title . PHP_EOL . PHP_EOL;
     $output .= $userStory . PHP_EOL . PHP_EOL;
     if (is_readable($imageFile)) {
         $output .= '![' . basename($imageFile, '.png') . '](./' . $fileInfo->getRelativePath() . basename($fileInfo->getPath()) . '/' . basename($imageFile) . ')' . PHP_EOL . PHP_EOL;
     }
     foreach ($scenarios as $scenario) {
         $scenario = trim($scenario);
         if (!$scenario) {
             continue;
         }
         $output .= $this->parseScenario($scenario, $fileInfo);
     }
     return $output;
 }
开发者ID:sourcerer-mike,项目名称:mdoc,代码行数:36,代码来源:Merge.php

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

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

示例8: parse

 /**
  * Parse the contents of the file.
  *
  * Example:
  *
  *     ---
  *     title: Title
  *     date: 2016-07-29
  *     ---
  *     Lorem Ipsum.
  *
  * @throws \RuntimeException
  *
  * @return $this
  */
 public function parse()
 {
     if ($this->file->isFile()) {
         if (!$this->file->isReadable()) {
             throw new \RuntimeException('Cannot read file');
         }
         // parse front matter
         preg_match('/' . self::PATTERN . '/s', $this->file->getContents(), $matches);
         // if not front matter, set body only
         if (!$matches) {
             $this->body = $this->file->getContents();
             return $this;
         }
         $this->frontmatter = trim($matches[1]);
         $this->body = trim($matches[2]);
     }
     return $this;
 }
开发者ID:narno,项目名称:phpoole-library,代码行数:33,代码来源:Parser.php

示例9: load

 /**
  * Load and parse data from cache file
  */
 public function load()
 {
     $files = new Filesystem();
     if ($files->exists($this->source)) {
         $file = new SplFileInfo($this->source, null, null);
         return unserialize($file->getContents());
     }
     return array();
 }
开发者ID:AlexWoroschilow,项目名称:wurst-rss,代码行数:12,代码来源:CacheFile.php

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

示例11: parseConfigFile

 /**
  * Parses a .platform.app.yaml file.
  *
  * @param \Symfony\Component\Finder\SplFileInfo $configFile
  *      The file to parse.
  *
  * @return array|null
  *      An array of configurations found in the file or null.
  */
 private function parseConfigFile(SplFileInfo $configFile)
 {
     $yaml = new Parser();
     try {
         return $yaml->parse($configFile->getContents());
     } catch (ParseException $e) {
         printf('Unable to parse the platform configuration file: %s', $configFile->getFilename());
     }
     return null;
 }
开发者ID:comm-press,项目名称:environment-manager,代码行数:19,代码来源:PlatformConfigParser.php

示例12: editFileAction

 /**
  * @Route("/file_manager/edit-file", name="spliced_cms_admin_file_manager_edit_file")
  * @Template("SplicedCmsBundle:Admin/FileManagement:edit_file.html.twig")
  */
 public function editFileAction()
 {
     $this->loadContext();
     if (!$this->file instanceof \SplFileInfo || !$this->file->getRealPath()) {
         return $this->redirect($this->generateUrl('spliced_cms_admin_file_manager', array('dir' => $this->baseDir->getRelativePath())));
     }
     $fileFormData = array('content' => $this->file->getContents());
     $fileForm = $this->createForm(new FileFormType($this->file), $fileFormData);
     return array_merge($this->getViewContext(), array('fileForm' => $fileForm->createView()));
 }
开发者ID:splicedmedia,项目名称:cms-bundle,代码行数:14,代码来源:FileManagementController.php

示例13: getVersionFromComposerJson

 private function getVersionFromComposerJson($dir)
 {
     $version = '_._._';
     /** @var SplFileInfo $composerFile */
     $composerFile = new SplFileInfo($dir . '/composer.json', '', '');
     if ($composerFile->isFile()) {
         $composerJson = json_decode($composerFile->getContents());
         return $composerJson->version;
     }
     return $version;
 }
开发者ID:sulu,项目名称:sulu,代码行数:11,代码来源:SuluVersionPass.php

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

示例15: getComposerObject

 /**
  * @param $lock
  *
  * @return mixed
  *
  * @throws \RunTimeException
  */
 private function getComposerObject($lock)
 {
     if (!is_file($lock)) {
         throw new \RuntimeException('Lock file does not exist.');
     }
     $file = new SplFileInfo($lock, null, null);
     $composer = json_decode($file->getContents());
     if (null === $composer || !isset($composer->packages)) {
         throw new \RuntimeException('Lock file is not valid.');
     }
     return $composer;
 }
开发者ID:kevintweber,项目名称:deprecation-detector,代码行数:19,代码来源:ComposerLoader.php


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