Пример #1
0
 /**
  * @param bool $skipSelection
  * @return \Doctrine\ORM\QueryBuilder|null
  * @throws \Trinity\Bundle\SearchBundle\Exception\SyntaxErrorException
  */
 public function getQueryBuilder($skipSelection = false)
 {
     if (null !== $this->dqlConverter) {
         return $this->dqlConverter->convert($this, $skipSelection);
     } else {
         return null;
     }
 }
Пример #2
0
 /**
  * @param $entityName
  *
  * @return array Entity class name, null if not found
  * @throws \Doctrine\ORM\ORMException
  * @internal param string $table Table name
  * @internal param EntityManager $em Entity manager
  */
 protected function getEntityStringColumns($entityName)
 {
     // Go through all the classes
     $classNames = $this->dqlConverter->getAvailableEntities();
     $annotationReader = new AnnotationReader();
     $searchingEntityName = strtolower($entityName);
     foreach ($classNames as $i => $className) {
         $className = $classNames[$i];
         $classMetaData = $this->em->getClassMetadata($className);
         $currentEntityName = strtolower($classMetaData->getReflectionClass()->getName());
         if ($currentEntityName === $searchingEntityName) {
             /** @var array $allColumnNames */
             $allColumnNames = $classMetaData->getFieldNames();
             $columnNames = [];
             foreach ($allColumnNames as $columnName) {
                 try {
                     $annotations = $annotationReader->getPropertyAnnotations(new \ReflectionProperty($classMetaData->getName(), $columnName));
                     if ($classMetaData->getTypeOfField($columnName) === 'string') {
                         $isEnum = false;
                         foreach ($annotations as $annotation) {
                             if ($annotation instanceof Choice) {
                                 $isEnum = true;
                                 break;
                             }
                         }
                         if (!$isEnum) {
                             $columnNames[] = $columnName;
                         }
                     }
                 } catch (\ReflectionException $e) {
                     //@todo @MartinMatejka what here, return false or return null or log?
                 }
             }
             return $columnNames;
         }
     }
     return [];
 }