예제 #1
0
 /**
  * @param Result $result
  */
 protected function postProcessResult(Result $result)
 {
     $dispatcher = $this->container->get('event_dispatcher');
     foreach ($result->getElements() as $item) {
         $dispatcher->dispatch(PrepareResultItemEvent::EVENT_NAME, new PrepareResultItemEvent($item));
     }
 }
예제 #2
0
 public function testToSearchResultData()
 {
     $resultArray = $this->result->toSearchResultData();
     $this->assertEquals(3, $resultArray['records_count']);
     $this->assertEquals(3, $resultArray['count']);
     $this->assertEquals('OroTestBundle:test', $resultArray['data'][0]['entity_name']);
     $this->assertEquals(2, $resultArray['data'][1]['record_id']);
     $this->assertEquals('test title 3', $resultArray['data'][2]['record_string']);
     $this->result1->toSearchResultData();
 }
예제 #3
0
 /**
  * Log query
  *
  * @param Result $result
  */
 protected function logQuery(Result $result)
 {
     $entityManager = $this->registry->getManagerForClass('Oro\\Bundle\\SearchBundle\\Entity\\Query');
     $logRecord = new QueryLog();
     $logRecord->setEntity(implode(',', array_values($result->getQuery()->getFrom())));
     $logRecord->setQuery(serialize($result->getQuery()->getCriteria()));
     $logRecord->setResultCount($result->count());
     $entityManager->persist($logRecord);
     $entityManager->flush($logRecord);
 }
예제 #4
0
 /**
  * Get id of entities excluded passed user
  *
  * @param Result $searchResults
  * @param User $user
  *
  * @return array
  */
 protected function getIdsByClass(Result $searchResults, User $user)
 {
     $userIds = $buIds = $orgIds = [];
     foreach ($searchResults->getElements() as $item) {
         $className = $item->getEntityName();
         if (ClassUtils::getRealClass($user) === $className && $user->getId() === $item->getRecordId()) {
             continue;
         }
         if ($className === 'Oro\\Bundle\\UserBundle\\Entity\\User') {
             $userIds[] = $item->getRecordId();
         } elseif ($className === 'Oro\\Bundle\\OrganizationBundle\\Entity\\BusinessUnit') {
             $buIds[] = $item->getRecordId();
         } elseif ($className === 'Oro\\Bundle\\OrganizationBundle\\Entity\\Organization') {
             $orgIds[] = $item->getRecordId();
         }
     }
     return [$userIds, $buIds, $orgIds];
 }
 /**
  * Log query
  *
  * @param \Oro\Bundle\SearchBundle\Query\Result $result
  */
 protected function logQuery(Result $result)
 {
     $logRecord = new QueryLog();
     $logRecord->setEntity(serialize($result->getQuery()->getFrom()));
     $logRecord->setQuery(serialize($result->getQuery()->getOptions()));
     $logRecord->setResultCount($result->count());
     $this->em->persist($logRecord);
     $this->em->flush();
 }