injections['selectManagerFactory']; } protected function getEntityManager() { return $this->injections['entityManager']; } protected function getAcl() { return $this->injections['acl']; } protected function getMetadata() { return $this->injections['metadata']; } public function find($query, $offset, $maxSize) { $entityNameList = $this->getConfig()->get('globalSearchEntityList'); $entityTypeCount = count($entityNameList); $list = array(); $count = 0; $total = 0; foreach ($entityNameList as $entityName) { if (!$this->getAcl()->check($entityName, 'read')) { continue; } $selectManager = $this->getSelectManagerFactory()->create($entityName); $selectParams = $selectManager->getSelectParams(array( 'where' => array( array( 'type' => 'textFilter', 'value' => $query ) ), 'asc' => true, 'sortBy' => 'name', 'offset' => round($offset / $entityTypeCount), 'maxSize' => round($maxSize / $entityTypeCount), ), true); $collection = $this->getEntityManager()->getRepository($entityName)->find($selectParams); $count += count($collection); $total += $this->getEntityManager()->getRepository($entityName)->count($selectParams); foreach ($collection as $entity) { $data = $entity->toArray(); $data['_scope'] = $entityName; $list[] = $data; } } return array( 'total' => $total, 'list' => $list, ); } }