本文整理汇总了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()));
}
示例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'));
}
示例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]]);
}
}
示例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");
}
示例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;
}
示例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)));
}
}
示例7: contains
/**
* @return Finder
*/
public function contains($pattern)
{
return parent::contains($pattern);
}