Rename a workspace.

@param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace
@param string                                                   $name
16421
public function rename(Workspace $workspace, $name)
    {
        $workspace->setName($name);
        $root = $this->resourceManager->getWorkspaceRoot($workspace);
        $root->setName($name);
        $this->om->persist($workspace);
        $this->om->persist($root);
        $this->om->flush();
    }
472495
public function create(array $data, Workspace $workspace)
    {
        $options = [Options::LIGHT_COPY, Options::REFRESH_UUID];
        // gets entity from raw data.
        $workspace = $this->deserialize($data, $workspace, $options);

        // creates the entity if allowed
        $this->checkPermission('CREATE', $workspace, [], true);

        if ($this->dispatch('create', 'pre', [$workspace, $options])) {
            $this->om->save($workspace);
            $this->dispatch('create', 'post', [$workspace, $options]);
        }

        return $workspace;
    }
1330901
public function rename(
        UUID $uuid,
        StringLiteral $name
    ) {
        $this->apply(new RoleRenamed($uuid, $name));
    }
777228
public function workspaceEditAction(Workspace $workspace)
    {
        if (!$this->authorization->isGranted('parameters', $workspace)) {
            throw new AccessDeniedException();
        }

        $wsRegisteredName = $workspace->getName();
        $wsRegisteredDisplayable = $workspace->isDisplayable();
        $workspaceAdminTool = $this->toolManager->getAdminToolByName('workspace_management');
        $isAdmin = $this->authorization->isGranted('OPEN', $workspaceAdminTool);
        $expDate = is_null($workspace->getCreationDate()) ? null : $this->utilities->intlDateFormat(
            $workspace->getEndDate()
        );
        $form = $this->formFactory->create(
            FormFactory::TYPE_WORKSPACE_EDIT,
            array(null, null, null, null, null, $isAdmin, $expDate),
            $workspace
        );
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $this->workspaceManager->editWorkspace($workspace);
            $this->workspaceManager->rename($workspace, $workspace->getName());
            $displayable = $workspace->isDisplayable();

            if (!$displayable && $displayable !== $wsRegisteredDisplayable) {
                $this->workspaceTagManager->deleteAllAdminRelationsFromWorkspace($workspace);
            }

            return $this->redirect(
                $this->generateUrl(
                    'claro_workspace_open_tool',
                    array(
                        'workspaceId' => $workspace->getId(),
                        'toolName' => 'parameters'
                    )
                )
            );
        } else {
            $workspace->setName($wsRegisteredName);
        }

        $user = $this->tokenStorage->getToken()->getUser();

        if ($workspace->getSelfRegistration()) {
            $url = $this->router->generate(
                'claro_workspace_subscription_url_generate',
                array('workspace' => $workspace->getId()),
                true
            );
        } else {
            $url = '';
        }

        return array(
            'form' => $form->createView(),
            'workspace' => $workspace,
            'url' => $url,
            'user' => $user
        );
    }
90752
public function renameTable(string $table, string $name)
    {
        $result = $this->connection->schemaCompiler()->renameTable($table, $name);
        $this->connection->command($result['sql'], $result['params']);
        $this->tableList = null;
        unset($this->columns[strtolower($table)]);
    }
642751
public function rename($name)
    {
        return $this->client->apiCall('groups.rename', [
            'channel' => $this->getId(),
            'name' => $name,
        ])->then(function () use ($name) {
            $this->data['name'] = $name;
            return $name;
        });
    }
86646
public static function rename(string $name, string $newName, bool $overwrite = true): void
	{
		NetteFileSystem::rename($name, $newName, $overwrite);
	}
1723
public function removeBrokenEntityReferences($workspaceName)
    {
        $this->dispatch(self::EVENT_NOTICE, 'Checking for broken entity references ...');

        /** @var \Neos\ContentRepository\Domain\Model\Workspace $workspace */
        $workspace = $this->workspaceRepository->findByIdentifier($workspaceName);

        $nodeTypesWithEntityReferences = [];
        foreach ($this->nodeTypeManager->getNodeTypes() as $nodeType) {
            /** @var NodeType $nodeType */
            foreach (array_keys($nodeType->getProperties()) as $propertyName) {
                $propertyType = $nodeType->getPropertyType($propertyName);
                if (strpos($propertyType, '\\') !== false) {
                    if (!isset($nodeTypesWithEntityReferences[$nodeType->getName()])) {
                        $nodeTypesWithEntityReferences[$nodeType->getName()] = [];
                    }
                    $nodeTypesWithEntityReferences[$nodeType->getName()][$propertyName] = $propertyType;
                }
            }
        }

        $nodesWithBrokenEntityReferences = [];
        $brokenReferencesCount = 0;
        foreach ($nodeTypesWithEntityReferences as $nodeTypeName => $properties) {
            $nodeDatas = $this->nodeDataRepository->findByParentAndNodeTypeRecursively('/', $nodeTypeName, $workspace);
            foreach ($nodeDatas as $nodeData) {
                /** @var NodeData $nodeData */
                foreach ($properties as $propertyName => $propertyType) {
                    $propertyValue = $nodeData->getProperty($propertyName);
                    $convertedProperty = null;

                    if (is_object($propertyValue)) {
                        $convertedProperty = $propertyValue;
                    }
                    if (is_string($propertyValue) && strlen($propertyValue) === 36) {
                        $convertedProperty = $this->propertyMapper->convert($propertyValue, $propertyType);
                        if ($convertedProperty === null) {
                            $nodesWithBrokenEntityReferences[$nodeData->getIdentifier()][$propertyName] = $nodeData;
                            $this->dispatch(self::EVENT_NOTICE, sprintf('Broken reference in "<i>%s</i>", property "<i>%s</i>" (<i>%s</i>) referring to <i>%s</i>.', $nodeData->getPath(), $nodeData->getIdentifier(), $propertyName, $propertyType, $propertyValue));
                            $brokenReferencesCount ++;
                        }
                    }
                    if ($convertedProperty instanceof Proxy) {
                        try {
                            $convertedProperty->__load();
                        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (EntityNotFoundException $e) {
                            $nodesWithBrokenEntityReferences[$nodeData->getIdentifier()][$propertyName] = $nodeData;
                            $this->dispatch(self::EVENT_NOTICE, sprintf('Broken reference in "<i>%s</i>", property "<i>%s</i>" (<i>%s</i>) referring to <i>%s</i>.', $nodeData->getPath(), $nodeData->getIdentifier(), $propertyName, $propertyType, $propertyValue));
                            $brokenReferencesCount ++;
                        }
                    }
                }
            }
        }

        if ($brokenReferencesCount === 0) {
            return;
        }
        $taskDescription = sprintf('Remove <i>%d</i> broken entity reference%s.', $brokenReferencesCount, $brokenReferencesCount > 1 ? 's' : '');
        $taskClosure = function () use ($nodesWithBrokenEntityReferences) {
            foreach ($nodesWithBrokenEntityReferences as $nodeIdentifier => $properties) {
                foreach ($properties as $propertyName => $nodeData) {
                    /** @var NodeData $nodeData */
                    $nodeData->setProperty($propertyName, null);
                }
            }
            $this->persistenceManager->persistAll();
        };
        $taskRequiresConfirmation = true;
        $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure, $taskRequiresConfirmation);
    }
512680
public function rename(User $user, $username)
    {
        $userRole = $this->roleManager->getUserRoleByUser($user);
        if ($userRole) $this->roleManager->renameUserRole($userRole, $user->getUsername());
        $user->setUsername($username);
        $personalWorkspaceName = $this->translator->trans('personal_workspace', array(), 'platform') . $user->getUsername();
        $pws = $user->getPersonalWorkspace();
        if ($pws) $this->workspaceManager->rename($pws, $personalWorkspaceName);
        $this->objectManager->persist($user);
        $this->objectManager->flush();
    }
178602
public function copy(Workspace $workspace, Workspace $newWorkspace, $model = false)
    {
        $transferManager = $this->container->get('claroline.manager.workspace.transfer');

        $fileBag = new FileBag();
        //these are the new workspace datas
        $data = $transferManager->serialize($workspace);
        $data = $transferManager->exportFiles($data, $fileBag, $workspace);

        if ($this->logger) {
            $transferManager->setLogger($this->logger);
        }

        if ($newWorkspace->getCode()) {
            unset($data['code']);
        }

        if ($newWorkspace->getName()) {
            unset($data['name']);
        }

        $options = [Options::LIGHT_COPY, Options::REFRESH_UUID];
        // gets entity from raw data.
        $workspace = $transferManager->deserialize($data, $newWorkspace, $options, $fileBag);
        $workspace->setIsModel($model);

        //set the manager
        $managerRole = $this->roleManager->getManagerRole($workspace);

        if ($managerRole && $workspace->getCreator()) {
            $user = $workspace->getCreator();
            $user->addRole($managerRole);
            $this->om->persist($user);
        }

        $root = $this->resourceManager->getWorkspaceRoot($workspace);

        if ($root) {
            $this->resourceManager->createRights($root);
        }

        $this->om->persist($workspace);
        $this->om->flush();

        return $workspace;
    }
627352
public function setBaseWorkspace(Workspace $workspace)
    {
        $userWorkspace = $this->userService->getPersonalWorkspace();
        $userWorkspace->setBaseWorkspace($workspace);
    }
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();
    }
895295
public function updateAction(Workspace $workspace)
    {
        if ($workspace->getTitle() === '') {
            $workspace->setTitle($workspace->getName());
        }

        $this->workspaceRepository->update($workspace);
        $this->addFlashMessage($this->translator->translateById('workspaces.workspaceHasBeenUpdated', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
        $this->redirect('index');
    }
253857
public function renameName($nameIndex, $newName)
    {
        $nameIndex = (int)$nameIndex;
        foreach ($this->positions as $position) {
            $source = $position->source;
            if ($source->nameIndex === $nameIndex) {
                $source->name = $newName;
            }
        }
    }
352185
public function onPrepareWorkspaceConstructWorkspaceInstance(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Creating Workspace.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));

        $workspace = new Workspace($event->getHost());
        $workspace->setReleasesDirectory($this->releasesDirectory);
        $workspace->setDataDirectory($this->dataDirectory);
        $workspace->setCacheDirectory($this->cacheDirectory);
        $workspace->setOtherDirectories($this->otherDirectories);

        $event->setWorkspace($workspace);

        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Created Workspace.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
    }
605528
public function renameProject(int $projectId, string $name): bool
    {
        return $this->updateProject($projectId, $name);
    }
976362
public function addNamespace($name)
    {
        if (!Arr::in($name, self::$_namespace)) {
            self::$_namespace[] = $name;
            return true;
        }

        return false;
    }