@param array $resourceNodeIds
@param bool  $executeQuery

@return Blog[]|\Doctrine\ORM\Query
17228
public function findByResourceNodeIds(array $resourceNodeIds, $executeQuery = true)
    {
        $query = $this->createQueryBuilder('blog')
            ->select(array('blog', 'bo', 'post'))
            ->join('blog.options', 'bo')
            ->leftJoin('blog.posts', 'post')
            ->where('blog.resourceNode IN (:resourceNodeIds)')
            ->setParameter('resourceNodeIds', $resourceNodeIds)
            ->getQuery()
        ;

        return $executeQuery ? $query->getResult() : $query;
    }
1253188
public function getResourceFromNode(ResourceNode $node)
    {
        return $this->om->getRepository($node->getClass())->findOneByResourceNode($node);
    }
589278
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodeAggregateIdentifiers = [];
        if (isset($arguments[0]) && !empty($arguments[0])) {
            $parsedFilter = FizzleParser::parseFilterGroup($arguments[0]);
            if ($this->earlyOptimizationOfFilters($flowQuery, $parsedFilter)) {
                return;
            }
        }

        /** @var TraversableNodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            foreach ($contextNode->findChildNodes() as $childNode) {
                if (!isset($outputNodeAggregateIdentifiers[(string)$childNode->getNodeAggregateIdentifier()])) {
                    $output[] = $childNode;
                    $outputNodeAggregateIdentifiers[(string)$childNode->getNodeAggregateIdentifier()] = true;
                }
            }
        }
        $flowQuery->setContext($output);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
689291
public function getAnswer(array $queries): array
    {
        $answers = [];
        foreach ($queries as $query) {
            $answer = $this->resourceRecords[$query->getName()][$query->getType()][$query->getClass()] ?? [];
            if (empty($answer)) {
                $answer = $this->findWildcardEntry($query);
            }

            $answers = array_merge($answers, $answer);
        }

        return $answers;
    }
210685
private function getQueryFields(string $resourceClass, ResourceMetadata $resourceMetadata, string $queryName, $itemConfiguration, $collectionConfiguration): array
    {
        $queryFields = [];
        $shortName = $resourceMetadata->getShortName();
        $fieldName = lcfirst('query' === $queryName ? $shortName : $queryName.$shortName);

        $deprecationReason = $resourceMetadata->getGraphqlAttribute($queryName, 'deprecation_reason', '', true);

        if (false !== $itemConfiguration && $fieldConfiguration = $this->getResourceFieldConfiguration($resourceClass, $resourceMetadata, null, $deprecationReason, new Type(Type::BUILTIN_TYPE_OBJECT, true, $resourceClass), $resourceClass, false, $queryName, null)) {
            $itemConfiguration['args'] = $itemConfiguration['args'] ?? ['id' => ['type' => GraphQLType::nonNull(GraphQLType::id())]];

            $queryFields[$fieldName] = array_merge($fieldConfiguration, $itemConfiguration);
        }

        if (false !== $collectionConfiguration && $fieldConfiguration = $this->getResourceFieldConfiguration($resourceClass, $resourceMetadata, null, $deprecationReason, new Type(Type::BUILTIN_TYPE_OBJECT, false, null, true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, $resourceClass)), $resourceClass, false, $queryName, null)) {
            $queryFields[Inflector::pluralize($fieldName)] = array_merge($fieldConfiguration, $collectionConfiguration);
        }

        return $queryFields;
    }
1317382
public function findAllByWorkspaceAndName(Workspace $workspace, $search, $executeQuery = true)
    {
        $upperSearch = strtoupper($search);
        $dql = '
            SELECT DISTINCT u FROM Claroline\CoreBundle\Entity\User u
            WHERE u IN (
            SELECT u1 FROM Claroline\CoreBundle\Entity\User u1
            JOIN u1.roles r1 WITH r1 IN (
                SELECT pr1 from Claroline\CoreBundle\Entity\Role pr1 WHERE pr1.type = :type
            )
            LEFT JOIN r1.workspace wol1
            WHERE wol1.id = :workspaceId AND u1 IN (
                SELECT us1 FROM Claroline\CoreBundle\Entity\User us1
                WHERE UPPER(us1.lastName) LIKE :search
                OR UPPER(us1.firstName) LIKE :search
                OR UPPER(us1.username) LIKE :search
                OR CONCAT(UPPER(us1.firstName), CONCAT(\' \', UPPER(us1.lastName))) LIKE :search
                OR CONCAT(UPPER(us1.lastName), CONCAT(\' \', UPPER(us1.firstName))) LIKE :search
            )
            AND u1.isRemoved = false
            )
            OR u IN (
            SELECT u2 FROM Claroline\CoreBundle\Entity\User u2
            JOIN u2.groups g2
            JOIN g2.roles r2 WITH r2 IN (
                SELECT pr2 from Claroline\CoreBundle\Entity\Role pr2 WHERE pr2.type = :type
            )
            LEFT JOIN r2.workspace wol2
            WHERE wol2.id = :workspaceId AND u IN (
                SELECT us2 FROM Claroline\CoreBundle\Entity\User us2
                WHERE UPPER(us2.lastName) LIKE :search
                OR UPPER(us2.firstName) LIKE :search
                OR UPPER(us2.username) LIKE :search
                OR CONCAT(UPPER(us2.firstName), CONCAT(\' \', UPPER(us2.lastName))) LIKE :search
                OR CONCAT(UPPER(us2.lastName), CONCAT(\' \', UPPER(us2.firstName))) LIKE :search
            )
            AND u2.isRemoved = false)
        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('workspaceId', $workspace->getId())
            ->setParameter('search', "%{$upperSearch}%");
        $query->setParameter('type', Role::WS_ROLE);

        return $executeQuery ? $query->getResult() : $query;
    }
115699
public function getResourceFromNode(ResourceNode $node)
    {
        try {
            /* @var AbstractResource $resource */
            $resource = $this->om->getRepository($node->getClass())->findOneBy(['resourceNode' => $node]);

            return $resource;
        } catch (\Exception $e) {
            $this->log('class '.$node->getClass().' doesnt exists', 'error');
        }
    }
1371641
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $parents = [];
        $parentNodeAggregateIdentifiers = [];
        /* @var TraversableNodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            $node = $contextNode;
            while (!$node->isRoot()) {
                $node = $node->findParentNode();
                if (isset($parentNodeAggregateIdentifiers[(string)$node->getNodeAggregateIdentifier()])) {
                    continue;
                }
                $parents[] = $node;
                $parentNodeAggregateIdentifiers[(string)$node->getNodeAggregateIdentifier()] = true;
            }
        }

        $flowQuery->setContext($parents);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
125726
public function findNonPlatformRolesForUser(User $user, $executeQuery = true)
    {
        $dql = '
            SELECT r
            FROM Claroline\CoreBundle\Entity\Role r
            JOIN r.workspace w
            JOIN r.users u
            WHERE w.creator != :user
            AND u = :user
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('user', $user);

        return $executeQuery ? $query->getResult() : $query;
    }
943978
public function findArchiveDatasByBlog(Blog $blog, $executeQuery = true)
    {
        $rsm = new ResultSetMapping();
        $rsm
        ->addScalarResult('c', 'count')
        ->addScalarResult('y', 'year')
        ->addScalarResult('m', 'month');

        $query = $this->getEntityManager()
            ->createNativeQuery('
                SELECT YEAR(p.publication_date) y, MONTH(p.publication_date) m, count(p.id) c
                FROM icap__blog_post p
                WHERE p.blog_id = :blog
                AND p.publication_date <= :currentDate
                AND p.status = :status
                GROUP BY y, m
                ORDER BY y, m DESC
            ', $rsm)
            ->setParameter('blog', $blog->getId())
            ->setParameter('currentDate', new \DateTime())
            ->setParameter('status', POST::STATUS_PUBLISHED)
        ;

        return $executeQuery ? $query->getResult() : $query;
    }
633225
private function getResourceNodeFilteredQuery(Request $request, ResourceNode $node)
    {
        $query = $request->query->all();
        $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : [];
        $query['hiddenFilters'] = array_merge($hiddenFilters, ['resourceNode' => $node]);

        return $query;
    }
174340
@Override
    public List<NodeInstanceLog> findNodeInstances(long processInstanceId, String nodeId) {
        EntityManager em = getEntityManager();
        Query query = em
            .createQuery("FROM NodeInstanceLog n WHERE n.processInstanceId = :processInstanceId AND n.nodeId = :nodeId ORDER BY date,id")
                .setParameter("processInstanceId", processInstanceId)
                .setParameter("nodeId", nodeId);
        return executeQuery(query, em, NodeInstanceLog.class);
    }
1289525
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodeAggregateIdentifiers = [];
        $until = [];

        foreach ($flowQuery->getContext() as $contextNode) {
            $prevNodes = $this->getPrevForNode($contextNode);

            if (isset($arguments[0]) && !empty($arguments[0])) {
                $untilQuery = new FlowQuery($prevNodes);
                $untilQuery->pushOperation('filter', [$arguments[0]]);

                $until = $untilQuery->get();
            }

            if (isset($until) && !empty($until)) {
                $until = end($until);
                $prevNodes = $this->getNodesUntil($prevNodes, $until);
            }

            if (!is_array($prevNodes)) {
                continue;
            }

            foreach ($prevNodes as $prevNode) {
                if ($prevNode !== null && !isset($outputNodeAggregateIdentifiers[(string)$prevNode->getNodeAggregateIdentifier()])) {
                    $outputNodeAggregateIdentifiers[(string)$prevNode->getNodeAggregateIdentifier()] = true;
                    $output[] = $prevNode;
                }
            }
        }

        $flowQuery->setContext($output);

        if (isset($arguments[1]) && !empty($arguments[1])) {
            $flowQuery->pushOperation('filter', [$arguments[1]]);
        }
    }
407282
public function select($query, $bindings = array())
    {
        $statement  = $this->getActivePdo()->prepare($query);

        if ($statement->execute($bindings)) {
            return $statement->fetchAll($this->fetchMode);
        }

        throw new DbException("Db execute fail [{$query}]");
    }
908100
public function getErrors(ResourceNode $resourceNode, array $userRoles): array
    {
        if (!$this->isGranted($resourceNode, $userRoles)) {
            // return restrictions details
            $errors = [
                'noRights' => !$this->hasRights($resourceNode, $userRoles),
                'deleted' => !$resourceNode->isActive(),
                'notPublished' => !$resourceNode->isPublished(),
            ];

            // optional restrictions
            // we return them only if they are enabled
            if (!empty($resourceNode->getAccessCode())) {
                $errors['locked'] = !$this->isUnlocked($resourceNode);
            }

            if (!empty($resourceNode->getAccessibleFrom()) || !empty($resourceNode->getAccessibleUntil())) {
                $errors['notStarted'] = !$this->isStarted($resourceNode);
                $errors['startDate'] = $resourceNode->getAccessibleFrom() ?
                    $resourceNode->getAccessibleFrom()->format('d/m/Y') :
                    null;
                $errors['ended'] = $this->isEnded($resourceNode);
            }

            if (!empty($resourceNode->getAllowedIps())) {
                $errors['invalidLocation'] = !$this->isIpAuthorized($resourceNode);
            }

            return $errors;
        }

        return [];
    }
1091073
public function getResourceIdsForTag($taggableType, $tag)
    {
        $results = $this->getTagsQueryBuilder($taggableType)
            ->andWhere('tag.'.$this->tagQueryField.' = :tag')
            ->setParameter('tag', $tag)
            ->select('tagging.resourceId')
            ->getQuery()
            ->execute(array(), AbstractQuery::HYDRATE_SCALAR)
        ;

        $ids = array();
        foreach ($results as $result) {
            $ids[] = $result['resourceId'];
        }

        return $ids;
    }
177588
protected function getNodeIdsInSite($siteId, DocumentManager $dm)
    {
        $qb = $dm->createQueryBuilder(Node::class)->hydrate(false);
        $qb->field('deleted')->equals(false)
            ->field('siteId')->equals($siteId)
            ->distinct('nodeId');

        return $qb->getQuery()->execute()->toArray();
    }