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


PHP Finder::contains方法代码示例

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


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

示例1: searchAction

 /**
  * @Route("/search")
  */
 public function searchAction(Request $request)
 {
     $search = new FileSearch();
     $dirList = $this->generateDirList();
     $form = $this->createForm(SearchType::class, $search, array('dir_list' => $dirList));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $searchFor = $form->get('searchFor')->getData();
         $fileType = $form->get('fileType')->getData();
         $searchDir = $form->get('searchDir')->getData();
         $finder = new Finder();
         if (isset($fileType)) {
             $finder->files()->name("*.{$fileType}");
         }
         if (isset($searchDir)) {
             $finder->files()->in($searchDir);
         } else {
             $finder->files()->in(__DIR__);
         }
         if (isset($searchFor)) {
             $finder->contains($searchFor);
         }
         if (isset($finder) && count($finder) > 0) {
             echo "<h3>Found results in {$searchDir}: </h3><br/>";
             foreach ($finder as $key => $value) {
                 echo "<h4> {$value} contains '{$searchFor}' </h4>";
             }
         } else {
             echo "No content '{$searchFor}' in '{$searchDir}'";
         }
     }
     return $this->render('MihailSearchBundle:randomsearch:search_form.html.twig', array('form' => $form->createView()));
 }
开发者ID:granets,项目名称:SearchBundle,代码行数:36,代码来源:SearchController.php

示例2: searchAction

 /**
  * @Route("/emo_simple_search_api_bundle/{searchContent}/{fileType}/{searchDir}")
  */
 public function searchAction($searchDir = "", $searchContent = "search text", $fileType = "php")
 {
     $finder = new Finder();
     if (isset($fileType)) {
         $finder->files()->name("*.{$fileType}");
     }
     if (isset($searchDir) && $searchDir !== "") {
         $finder->files()->in($searchDir);
     } else {
         $finder->files()->in(__DIR__);
     }
     if (isset($searchContent)) {
         $finder->contains($searchContent);
     }
     $result = array('result' => "No content '{$searchContent}' in '{$searchDir}'");
     if (isset($finder) && count($finder) > 0) {
         $result['result'] = "Found results in {$searchDir}";
         foreach ($finder as $key => $value) {
             $result[] = "{$value} contains '{$searchContent}'";
         }
     }
     return new Response(json_encode($result), 200, array('Content-Type' => 'application/json'));
 }
开发者ID:emiliyank,项目名称:SimpleSearchApiBundle,代码行数:26,代码来源:SimpleSearchController2.php

示例3: find

 /**
  * Find in files.
  *
  * @param string      $query
  * @param string      $path
  * @param string      $name
  * @param bool|string $contains
  * @param int         $priority
  */
 private function find($query, $path = 'theme', $name = '*.twig', $contains = false, $priority = 0)
 {
     if (!$this->showFiles) {
         return;
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->notName('*~')->in($this->app['resources']->getPath($path));
     if ($name) {
         $finder->name($name);
     }
     if ($contains) {
         $finder->contains($contains);
     }
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         $relativePathname = $file->getRelativePathname();
         $filename = $file->getFilename();
         $this->register(['label' => sprintf("%s » <span>%s</span>", Trans::__('Edit file'), $filename), 'path' => $this->generatePath('fileedit', ['namespace' => 'theme', 'file' => $relativePathname]), 'description' => '', 'priority' => self::OMNISEARCH_FILE + $priority, 'keywords' => ['Edit file', $filename, $query]]);
     }
 }
开发者ID:nuffer,项目名称:bolt,代码行数:29,代码来源:Omnisearch.php

示例4: hasView

 /**
  * @param string $template
  *
  * @return bool
  */
 public function hasView($template)
 {
     $finder = new Finder();
     $finder->in($this->template_paths);
     return $finder->contains($template) or $finder->contains("{$template}.php");
 }
开发者ID:anctemarry27,项目名称:cogs,代码行数:11,代码来源:AbstractView.php

示例5: createFinder

 /**
  * @param  InputInterface $input
  * @return Finder
  */
 public function createFinder(InputInterface $input)
 {
     $finder = new Finder();
     $finder->files();
     foreach ($input->getArgument('directory') as $dir) {
         $finder->in($dir);
     }
     foreach ($input->getOption('not-dir') as $ignoreDir) {
         $finder->exclude($ignoreDir);
     }
     foreach ($input->getOption('file-name') as $pattern) {
         $finder->name($pattern);
     }
     foreach ($input->getOption('not-file-name') as $pattern) {
         $finder->notName($pattern);
     }
     foreach ($input->getOption('contains') as $pattern) {
         $finder->contains($pattern);
     }
     foreach ($input->getOption('not-contains') as $pattern) {
         $finder->notContains($pattern);
     }
     foreach ($input->getOption('path') as $pattern) {
         $finder->path($pattern);
     }
     foreach ($input->getOption('not-path') as $pattern) {
         $finder->notPath($pattern);
     }
     if ($size = $input->getOption('size')) {
         $finder->size($size);
     }
     if ($modified = $input->getOption('modified')) {
         $finder->date($modified);
     }
     if ($depth = $input->getOption('depth')) {
         $finder->depth($depth);
     }
     return $finder;
 }
开发者ID:hanneskod,项目名称:phpfind,代码行数:43,代码来源:Command.php

示例6: find

 /**
  * Find in files
  *
  * @param type        $query
  * @param string      $folder
  * @param string      $name
  * @param bool|string $contains
  * @param int         $priority
  */
 private function find($query, $folder = '/theme', $name = '*.twig', $contains = false, $priority = 0)
 {
     if (!$this->showFiles) {
         return;
     }
     $finder = new Finder();
     $finder->files()->ignoreVCS(true)->notName('*~')->in(BOLT_PROJECT_ROOT_DIR . $folder);
     if ($name) {
         $finder->name($name);
     }
     if ($contains) {
         $finder->contains($contains);
     }
     foreach ($finder as $file) {
         $relativePathname = $file->getRelativePathname();
         $filename = $file->getFilename();
         $this->register(array('label' => sprintf("%s » <span>%s</span>", __('Edit file'), $filename), 'path' => $this->backend . 'file/edit/theme/' . $relativePathname, 'description' => '', 'priority' => self::OMNISEARCH_FILE + $priority, 'keywords' => array('Edit file', $filename, $query)));
     }
 }
开发者ID:ArdKuijpers,项目名称:bolt,代码行数:28,代码来源:Omnisearch.php

示例7: contains

 /**
  * @return Finder
  */
 public function contains($pattern)
 {
     return parent::contains($pattern);
 }
开发者ID:stopsopa,项目名称:utils,代码行数:7,代码来源:Finder.php


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