Query results before filtering.

@param int $rootEntityIdentifier

@return int
358474
private function getCountAllResults($rootEntityIdentifier)
    {
        $qb = $this->em->createQueryBuilder();
        $qb->select('count(distinct '.$this->tableName.'.'.$rootEntityIdentifier.')');
        $qb->from($this->entity, $this->tableName);

        $this->setLeftJoins($qb);
        $this->setWhereAllCallback($qb);

        return (int) $qb->getQuery()->getSingleScalarResult();
    }
14179
public function countOpenByIdentifier($identifier): int
    {
        $queryBuilder = $this->createQuery();
        $where = $queryBuilder->expr()->andX(
            $queryBuilder->expr()->eq('cache_url', $queryBuilder->createNamedParameter($identifier)),
            $queryBuilder->expr()->eq('call_date', $queryBuilder->createNamedParameter(0))
        );

        return (int)$queryBuilder->select('uid')
            ->from($this->getTableName())
            ->where($where)
            ->execute()
            ->rowCount();
    }
1254665
public function getRightRecord(Entity $rightEntity, $foreignKey, $primaryValue)
    {
        if (!$primaryValue) {
            return null;
        }

        if ($this->inheritRightRepository) {
            $rightEntity->setRepository($this->getLeftEntity()->getRepository());
        }
        $entity = $rightEntity->where($foreignKey, $primaryValue);

        /**
         * Add conditions applied on query.
         */
        foreach ($this->getQuery()->getWhere()->getChildren() as $condition) {
            $entity->where(
                function(Parenthesis $parenthesis) use ($condition) {
                    $parenthesis->push($condition);
                }
            );
        }

        foreach ($this->getQuery()->getBinds('where') as $bind) {
            $entity->getQuery()->bind($bind, 'where');
        }
        
        return (new GetRecords($rightEntity))->executeOne();
    }
473696
public function findByIdentifier($identifier)
    {
        $object = $this->persistenceManager->getObjectByIdentifier($identifier, $this->entityClassName);
        if ($object === null) {
            foreach ($this->addedResources as $addedResource) {
                if ($this->persistenceManager->getIdentifierByObject($addedResource) === $identifier) {
                    $object = $addedResource;
                    break;
                }
            }
        }

        return $object;
    }
1108689
public function checkUserFollowsChannel($userIdentifier, $channelIdentifier)
    {
        if ($this->apiVersionIsGreaterThanV3()) {
            if (!is_numeric($userIdentifier)) {
                throw new InvalidIdentifierException('user');
            }

            if (!is_numeric($channelIdentifier)) {
                throw new InvalidIdentifierException('channel');
            }
        }

        return $this->get(sprintf('users/%s/follows/channels/%s', $userIdentifier, $channelIdentifier));
    }
1045871
protected function getSearchableFields($fieldIdentifier)
    {
        if ($fieldIdentifier === null) {
            return;
        }

        $query = $this->dbHandler->createSelectQuery();
        $query
            ->select($this->dbHandler->quoteColumn('id', 'ezcontentclass_attribute'))
            ->from($this->dbHandler->quoteTable('ezcontentclass_attribute'))
            ->where(
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn(
                            'is_searchable',
                            'ezcontentclass_attribute'
                        ),
                        $query->bindValue(1, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn(
                            'data_type_string',
                            'ezcontentclass_attribute'
                        ),
                        $query->bindValue('eztags')
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('identifier', 'ezcontentclass_attribute'),
                        $query->bindValue($fieldIdentifier)
                    )
                )
            );

        $statement = $query->prepare();
        $statement->execute();
        $fieldDefinitionIds = $statement->fetchAll(\PDO::FETCH_COLUMN);

        if (empty($fieldDefinitionIds)) {
            throw new InvalidArgumentException(
                '$criterion->target',
                "No searchable fields found for the given criterion target '{$fieldIdentifier}'."
            );
        }

        return $fieldDefinitionIds;
    }
77866
function processAuthResultForEntity(err, entity) {

        if(stopAll) return

        if(err && err.code !== ACL_ERROR_CODE) {
          stopAll = true
          callback(err, undefined)
        } else {

          if(entity) {
            filteredEntities.push(entity)
          }
          callbackCount ++
          if(callbackCount === entities.length) {
            callback(undefined, filteredEntities)
          }
        }
      }
532319
public function getEntity($entityId)
    {
        if (isset($this->entities[$entityId])) {
            return $this->entities[$entityId];
        }

        $this->entities[$entityId] = $this->client->getEntity($entityId);

        return $this->entities[$entityId];
    }
67931
protected function deleteResource($identifier): int
    {
        try {
            $query = $this->getConnection()->createQueryBuilder();

            $query
                ->delete($this->getTableNameForWriting())
                ->where($this->getPrimaryKeyName() . '=' . $this->createTypedParameter($query, $identifier));

            $numberOfDeleted = $query->execute();
            assert(is_int($numberOfDeleted) === true);

            return $numberOfDeleted;
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
            $message = 'Resource deletion failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
703331
function checkIdentifierGivenToAnyUser(array $identifiers)
    {
        $response = $this->call( new Command\Members\Exists($identifiers) );
        if ( $ex = $response->hasException() )
            throw $ex;

        $r = $response->expected();
        $r = ($r instanceof iDataEntity) ? $r->get('result') : $r;
        return $r;
    }
486125
public function findOneByIdentifier($identifier) {
		$statement = $this->connection->prepare('SELECT * FROM objects WHERE __identifier__ = :identifier LIMIT 1');
		$statement->bindValue(':identifier', $identifier);

		return $statement->execute()->fetchArray(SQLITE3_ASSOC);
	}
53643
public function getHitEntityAttribute($hitIdentifier, $entityIdentifier)
	{
		return isset($this->entityHitMapping[$entityIdentifier][$hitIdentifier]) ?
				$this->entityHitMapping[$entityIdentifier][$hitIdentifier] : null;
	}
876824
public function get(string $entryIdentifier)
    {
        $value = $this->memcache->get($this->identifierPrefix . $entryIdentifier);
        if (substr($value, 0, 13) === 'Flow*chunked:') {
            list(, $chunkCount) = explode(':', $value);
            $value = '';
            for ($chunkNumber = 1; $chunkNumber < $chunkCount; $chunkNumber++) {
                $value .= $this->memcache->get($this->identifierPrefix . $entryIdentifier . '_chunk_' . $chunkNumber);
            }
        }
        return $value;
    }
752761
public function getIdentifier() : ?int 
    {
        if ( ! $this->hasIdentifier()) {
            $this->setIdentifier($this->getDefaultIdentifier());
        }
        return $this->identifier;
    }
554322
public function getUserEntity($user)
    {
        $result = null;
        if ($user instanceof UserEntity) {
            $result = $user;
        } else {
            $u = $this->getUser($user);
            if ($u !== null) {
                $result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u->getUserID());
            }
        }

        return $result;
    }
1064474
public function toEntity(
        $parent,
        ResourceTransformer $resourceTransformer,
        PropertyResolver $propertyResolver,
        PropertySetter $propertySetter,
        EntityFactory $factory,
        Context $context
    ) {
        $children = $this->getChildrenToProcess();

        $childrenToAdd = [];
        $childrenToEdit = [];

        /**
         * Keep a list of all identifies we've touched, so we can removed those we haven't
         * @var PropertyValueCollection[] $identifiersToKeep
         */
        $identifiersToKeep = [];

        /** @var RelationshipField $field */
        $field = $this->getField();

        foreach ($children as $child) {
            if (!$child) {
                continue;
            }

            /** @var RESTResource $child */

            /** @var bool $isNew */
            $isNew = $child->isNew();

            $childIdentifiers = $child->getProperties()->getIdentifiers();

            $childEntity = null;
            if (!$isNew) {
                $childEntity = $this->getChildByIdentifiers(
                    $resourceTransformer,
                    $propertyResolver,
                    $parent,
                    $childIdentifiers,
                    $context
                );

                if ($childEntity) {
                    $identifiersToKeep[] = $childIdentifiers;
                }
            }

            // Do we just link the resource? In this case we can't edit it right now.
            if ($field->canLinkExistingEntities()) {
                $entity = $factory->resolveLinkedEntity(
                    $parent,
                    $child->getResourceDefinition()->getEntityClassName(),
                    $childIdentifiers->toMap(),
                    $context
                );

                if ($entity) {
                    $childrenToAdd[] = $entity;
                    $identifiersToKeep[] = $childIdentifiers;
                    continue;
                }
            }

            // Is this a new child? We might not be able to add it...
            if (!$childEntity && !$field->canCreateNewChildren()) {
                throw new InvalidPropertyException(
                    "Only existing items can be linked to " . get_class($parent) . "->" . $field->getName()
                );
            }

            $entity = $resourceTransformer->toEntity(
                $child,
                $child->getResourceDefinition(),
                $factory,
                $context,
                $childEntity
            );

            if (!isset($childEntity)) {
                $childrenToAdd[] = $entity;
            } else {
                $childrenToEdit[] = $entity;
            }
        }

        if (count($childrenToAdd) > 0) {
            $this->addChildren(
                $resourceTransformer,
                $propertySetter,
                $parent,
                $this->getField(),
                $childrenToAdd,
                $context
            );
        }

        if (count($childrenToEdit) > 0) {
            $this->editChildren(
                $resourceTransformer,
                $propertySetter,
                $parent,
                $this->getField(),
                $childrenToEdit,
                $context
            );
        }

        // Notify the setter to remove all children that haven't been touched (in the range defined in the context)
        $this->removeAllChildrenExcept(
            $resourceTransformer,
            $propertyResolver,
            $propertySetter,
            $parent,
            $this->getField(),
            $identifiersToKeep,
            $context
        );
    }
156021
@Override
    public EntityIdentifier[] searchForEntities(String query, SearchMethod method)
            throws GroupsException {
        boolean allowPartial = true;

        switch (method) {
            case DISCRETE:
                allowPartial = false;
                break;
            case STARTS_WITH:
                query = query + "%";
                break;
            case ENDS_WITH:
                query = "%" + query;
                break;
            case CONTAINS:
                query = "%" + query + "%";
                break;
            default:
                throw new GroupsException("Unknown search type");
        }

        // get the list of matching portlet definitions
        final List<IPortletDefinition> definitions =
                this.portletDefinitionRegistry.searchForPortlets(query, allowPartial);
        if (log.isDebugEnabled()) {
            log.debug("Found " + definitions.size() + " matching definitions for query " + query);
        }

        // initialize an appropriately-sized array of EntityIdentifiers
        final EntityIdentifier[] identifiers = new EntityIdentifier[definitions.size()];

        // add an identifier for each matching portlet
        for (final ListIterator<IPortletDefinition> defIter = definitions.listIterator();
                defIter.hasNext(); ) {
            final IPortletDefinition definition = defIter.next();
            identifiers[defIter.previousIndex()] =
                    new EntityIdentifier(
                            definition.getPortletDefinitionId().getStringId(), this.getType());
        }

        return identifiers;
    }