Neos\Media\Domain\Repository\TagRepository::findBySearchTerm PHP Method

findBySearchTerm() public method

public findBySearchTerm ( string $searchTerm ) : Neos\Flow\Persistence\QueryResultInterface
$searchTerm string
return Neos\Flow\Persistence\QueryResultInterface
    public function findBySearchTerm($searchTerm)
    {
        $query = $this->createQuery();
        return $query->matching($query->like('label', '%' . $searchTerm . '%'))->execute();
    }

Usage Example

 /**
  * @test
  */
 public function findBySearchTermReturnsFilteredResult()
 {
     $tag1 = new Tag('foobar');
     $tag2 = new Tag('foo bar');
     $tag3 = new Tag('bar foo bar');
     $this->tagRepository->add($tag1);
     $this->tagRepository->add($tag2);
     $this->tagRepository->add($tag3);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->assertCount(3, $this->tagRepository->findBySearchTerm('foo'));
     $this->assertCount(2, $this->tagRepository->findBySearchTerm('foo bar'));
     $this->assertCount(1, $this->tagRepository->findBySearchTerm(' foo '));
 }
All Usage Examples Of Neos\Media\Domain\Repository\TagRepository::findBySearchTerm