Search a ResourceNode wich is persisted but not flushed yet

@param Workspace $workspace
@param $name
@param ResourceNode $parent

@return ResourceNode
332696
public function getNodeScheduledForInsert(Workspace $workspace, $name, $parent = null)
    {
        $scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions();
        $res = null;

        foreach ($scheduledForInsert as $entity) {
            if (get_class($entity) === 'Claroline\CoreBundle\Entity\Resource\ResourceNode') {
                if ($entity->getWorkspace()->getCode() === $workspace->getCode() &&
                    $entity->getName() === $name &&
                    $entity->getParent() == $parent) {

                    return $entity;
                }
            }
        }

        return $res;
    }
29648
public function whereParentIs(ResourceNode $parent)
    {
        $this->addWhereClause('node.parent = :ar_parentId');
        $this->parameters[':ar_parentId'] = $parent->getId();

        return $this;
    }
1339531
public CollectionRequest<User> findByWorkspace(String workspace) {
    
        String path = String.format("/workspaces/%s/users", workspace);
        return new CollectionRequest<User>(this, User.class, path, "GET");
    }
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;
    }
917854
public function removeContentDimensionsFromRootAndSitesNode($workspaceName)
    {
        $workspace = $this->workspaceRepository->findByIdentifier($workspaceName);
        /** @noinspection PhpUndefinedMethodInspection */
        $rootNodes = $this->nodeDataRepository->findByPath('/', $workspace);
        /** @noinspection PhpUndefinedMethodInspection */
        $sitesNodes = $this->nodeDataRepository->findByPath('/sites', $workspace);
        $this->dispatch(self::EVENT_NOTICE, 'Checking for root and site nodes with content dimensions set ...');
        /** @var \Neos\ContentRepository\Domain\Model\NodeData $rootNode */
        foreach ($rootNodes as $rootNode) {
            if ($rootNode->getDimensionValues() !== []) {
                $taskDescription = 'Remove content dimensions from root node';
                $taskClosure = function () use ($rootNode) {
                    $rootNode->setDimensions([]);
                    $this->nodeDataRepository->update($rootNode);
                };
                $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure);
            }
        }
        /** @var \Neos\ContentRepository\Domain\Model\NodeData $sitesNode */
        foreach ($sitesNodes as $sitesNode) {
            if ($sitesNode->getDimensionValues() !== []) {
                $taskDescription = 'Remove content dimensions from node "/sites"';
                $taskClosure = function () use ($sitesNode) {
                    $sitesNode->setDimensions([]);
                    $this->nodeDataRepository->update($sitesNode);
                };
                $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure);
            }
        }
    }
700247
public function findByWorkspace(Workspace $workspace, $orderedBy = 'id', $order = 'ASC')
    {
        $dql = "
            SELECT r FROM Claroline\CoreBundle\Entity\Role r
            JOIN r.workspace ws
            WHERE ws.id = :workspaceId
            ORDER BY r.{$orderedBy} {$order}
        ";
        $query = $this->_em->createQuery($dql);
        $query->setParameter('workspaceId', $workspace->getId());

        return $query->getResult();
    }
370742
public function countResourcesByType($workspace = null, $organizations = null)
    {
        $qb = $this
            ->createQueryBuilder('rType')
            ->select('rType.id, rType.name, COUNT(rs.id) AS total')
            ->leftJoin('Claroline\CoreBundle\Entity\Resource\ResourceNode', 'rs', 'WITH', 'rType = rs.resourceType')
            ->andWhere('rType.name != :directoryName')
            ->andWhere('rs.active = 1')
            ->setParameter('directoryName', 'directory')
            ->groupBy('rType.id')
            ->orderBy('total', 'DESC');

        if (!empty($workspace)) {
            $qb->leftJoin('Claroline\CoreBundle\Entity\Workspace\Workspace', 'ws', 'WITH', 'ws = rs.workspace')
                ->andWhere('ws = :workspace')
                ->setParameter('workspace', $workspace);
        }

        if (!empty($organizations)) {
            $qb->leftJoin('Claroline\CoreBundle\Entity\Workspace\Workspace', 'ws', 'WITH', 'ws = rs.workspace')
                ->join('ws.organizations', 'orgas')
                ->andWhere('orgas IN (:organizations)')
                ->setParameter('organizations', $organizations);
        }

        return $qb->getQuery()->getResult();
    }
1159382
private function getParentNode($parent, $webspaceKey, $languageCode)
    {
        if (null != $parent) {
            return $this->getMapper()->load($parent, $webspaceKey, $languageCode);
        } else {
            return $this->getMapper()->loadStartPage($webspaceKey, $languageCode);
        }
    }
471564
public function findSectionOrCreate($name, Section $parent = null, $priority = 1)
    {
        if (is_null($parent)) {
            $parent = $this->getRootSection();
        }

        $section = $this->findSection($name, $parent);

        if (is_null($section)) {
            $section = $this->addSection($name, $parent, $priority);
        }

        return $section;
    }
652964
public function findByUserAndWorkspace(User $user, Workspace $workspace)
    {
        $dql = '
            SELECT
                n.name AS title,
                m.value AS mark,
                r.total AS total
            FROM Claroline\ResultBundle\Entity\Result r
            JOIN r.resourceNode n
            JOIN n.workspace w
            JOIN r.marks m
            JOIN m.user u
            WHERE w = :workspace
            AND u = :user
            ORDER BY n.creationDate DESC, n.id
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameters([
            'workspace' => $workspace,
            'user' => $user,
        ]);

        return $query->getArrayResult();
    }
686191
private function getDisplay(Workspace $workspace)
    {
        $options = $workspace->getOptions()->getDetails();

        $openResource = null;
        if (isset($options['workspace_opening_resource']) && $options['workspace_opening_resource']) {
            $resource = $this->om
                ->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceNode')
                ->findOneBy(['id' => $options['workspace_opening_resource']]);

            if (!empty($resource)) {
                $openResource = $this->resNodeSerializer->serialize($resource);
            }
        }

        return [
            'color' => !empty($options['background_color']) ? $options['background_color'] : null,
            'showTools' => !isset($options['hide_tools_menu']) || !$options['hide_tools_menu'],
            'openResource' => $openResource,
        ];
    }
1093165
protected function materializeToWorkspace($workspace)
    {
        $newNodeData = new NodeData($this->path, $workspace, $this->identifier, $this->dimensionValues);
        $this->nodeDataRepository->add($newNodeData);

        $newNodeData->similarize($this);

        return $newNodeData;
    }
1150872
public function mysql($name, Child $parent)
    {
        if (empty($name)) {
            return null;
        }
        if($parent->root == null){
            $parent->root = $parent;
        }
        $root = $parent->root;
        $core_name = MysqlAsynPool::AsynName . ":" .$name;
        if ($root->hasChild($core_name)) {
            return $root->getChild($core_name);
        }
        $mysql_pool = get_instance()->getAsynPool($name);
        if($mysql_pool == null) return null;
        $db = $mysql_pool->installDbBuilder();
        $db->setContext($root->getContext());
        $root->addChild($db);
        return $db;
    }
771233
public function importInExistingWorkspace(Configuration $configuration, Workspace $workspace)
    {
        $root = $this->resourceManager->getResourceFromNode($this->resourceManager->getWorkspaceRoot($workspace));
        $wsRoles = $this->roleManager->getRolesByWorkspace($workspace);
        $entityRoles = [];

        foreach ($wsRoles as $wsRole) {
            $entityRoles[$this->roleManager->getWorkspaceRoleBaseName($wsRole)] = $wsRole;
        }

        $workspace = $this->container->get('claroline.manager.transfert_manager')->importResources(
            $configuration,
            $workspace->getCreator(),
            $root->getResourceNode()
        );

        $this->importRichText();

        return $workspace;
    }
228468
public function countResources(Workspace $workspace)
    {
        //@todo count directory from dql
        $root = $this->resourceManager->getWorkspaceRoot($workspace);
        if (!$root) return 0;
        $descendants = $this->resourceManager->getDescendants($root);

        return count($descendants);
    }
1145507
public function findOutsidersByWorkspaceRolesAndName(
        array $roles,
        $name,
        Workspace $workspace,
        $getQuery = false
    )
    {
        //feel free to make this request easier if you can
        $search = strtoupper($name);

        $dql = "
            SELECT u FROM Claroline\CoreBundle\Entity\Group u
            WHERE u NOT IN (
                SELECT u2 FROM Claroline\CoreBundle\Entity\Group u2
                JOIN u2.roles r WHERE r IN (:roles) AND
                u2 NOT IN (
                    SELECT u3 FROM Claroline\CoreBundle\Entity\Group u3
                    JOIN u3.roles r2
                    JOIN r2.workspace ws
                    WHERE r2 NOT IN (:roles)
                    AND ws = :wsId
                )
            )
            AND UPPER(u.name) LIKE :search
            ";

        $query = $this->_em->createQuery($dql);
        $query->setParameter('roles', $roles);
        $query->setParameter('wsId', $workspace);
        $query->setParameter('search', "%{$search}%");

        return $getQuery ? $query : $query->getResult();
    }
415602
public function serialize(Workspace $workspace)
    {
        $serialized = $this->serializer->serialize($workspace, [Options::REFRESH_UUID]);

        //if roles duplicatas, remove them
        $roles = $serialized['roles'];

        foreach ($roles as $role) {
            $uniques[$role['translationKey']] = ['type' => $role['type']];
        }

        $roles = [];
        foreach ($uniques as $key => $val) {
            $val['translationKey'] = $key;
            $roles[] = $val;
        }

        $serialized['roles'] = $roles;

        //we want to load  the ressources first
        $ot = $workspace->getOrderedTools()->toArray();

        $idx = 0;

        foreach ($ot as $key => $tool) {
            if ('resource_manager' === $tool->getName()) {
                $idx = $key;
            }
        }

        $first = $ot[$idx];
        unset($ot[$idx]);
        array_unshift($ot, $first);

        $serialized['orderedTools'] = array_map(function (OrderedTool $tool) {
            $data = $this->ots->serialize($tool, [Options::SERIALIZE_TOOL, Options::REFRESH_UUID]);

            return $data;
        }, $ot);

        return $serialized;
    }