當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。