Ejemplo n.º 1
0
 protected function getCacheId()
 {
     $hints = $this->query->getHints();
     ksort($hints);
     $types = array();
     foreach ($this->query->getParameters() as $parameter) {
         $types[$parameter->getName()] = $parameter->getType();
     }
     $platform = $this->query->getEntityManager()->getConnection()->getDatabasePlatform()->getName();
     return md5(serialize(['dql' => $this->query->getDQL(), 'platform' => $platform, 'filters' => $this->query->getEntityManager()->hasFilters() ? $this->query->getEntityManager()->getFilters()->getHash() : '', 'firstResult' => $this->query->getFirstResult(), 'maxResult' => $this->query->getMaxResults(), 'hydrationMode' => $this->query->getHydrationMode(), 'types' => $types, 'hints' => $hints, 'salt' => __CLASS__ . 'V1']));
 }
Ejemplo n.º 2
0
 /**
  * Resolve DQL alias into class metadata
  *
  * @param  AbstractQuery $query
  * @param  string        $alias
  * @return array         | null
  */
 protected function getEntityFromAlias(AbstractQuery $query, $alias = null)
 {
     $em = $query->getEntityManager();
     $ast = $query->getAST();
     $fromClause = $ast->fromClause;
     foreach ($fromClause->identificationVariableDeclarations as $root) {
         $className = $root->rangeVariableDeclaration->abstractSchemaName;
         $classAlias = $root->rangeVariableDeclaration->aliasIdentificationVariable;
         if ($classAlias == $alias || null === $alias) {
             return array('alias' => $classAlias, 'metadata' => $em->getClassMetadata($className));
         } else {
             foreach ($root->joins as $join) {
                 $joinAlias = $join->joinAssociationDeclaration->aliasIdentificationVariable;
                 $joinField = $join->joinAssociationDeclaration->joinAssociationPathExpression->associationField;
                 if ($joinAlias == $alias) {
                     $metadata = $em->getClassMetadata($className);
                     $joinName = $metadata->associationMappings[$joinField]['targetEntity'];
                     return array('alias' => $joinAlias, 'metadata' => $em->getClassMetadata($joinName));
                 }
             }
         }
     }
 }
 /**
  * @param AbstractQuery $query
  * @param int           $batchSize
  *
  * @return self
  */
 public static function fromQuery(AbstractQuery $query, $batchSize)
 {
     return new self($query->iterate(), $query->getEntityManager(), $batchSize);
 }