for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SumoCoders\FrameworkSearchBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* IndexItemRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class IndexItemRepository extends EntityRepository
{
public function search($term)
$query = $this->createQueryBuilder('r')
->where('r.value LIKE :term')
->setParameter('term', '%' . $term . '%')
->getQuery();
$results = $query->getResult();
if (empty($results)) {
return null;
}
// group per class
$items = array();
foreach ($results as $indexItem) {
/** @var $indexItem IndexItem */
$class = $indexItem->getObjectType();
$id = $indexItem->getOtherId();
if (!isset($items[$class][$id])) {
$items[$class][$id] = 0;
$items[$class][$id]++;
return $items;