/**
  * Repair inconsistent nodes
  *
  * This command analyzes and repairs the node tree structure and individual nodes
  * based on the current node type configuration.
  *
  * The following checks will be performed:
  *
  * {pluginDescriptions}
  * <b>Examples:</b>
  *
  * ./flow node:repair
  *
  * ./flow node:repair --node-type TYPO3.Neos.NodeTypes:Page
  *
  * @param string $nodeType Node type name, if empty update all declared node types
  * @param string $workspace Workspace name, default is 'live'
  * @param boolean $dryRun Don't do anything, but report actions
  * @param boolean $cleanup If FALSE, cleanup tasks are skipped
  * @return void
  */
 public function repairCommand($nodeType = null, $workspace = 'live', $dryRun = false, $cleanup = true)
 {
     $this->pluginConfigurations = self::detectPlugins($this->objectManager);
     if ($this->workspaceRepository->countByName($workspace) === 0) {
         $this->outputLine('Workspace "%s" does not exist', array($workspace));
         exit(1);
     }
     if ($nodeType !== null) {
         if ($this->nodeTypeManager->hasNodeType($nodeType)) {
             $nodeType = $this->nodeTypeManager->getNodeType($nodeType);
         } else {
             $this->outputLine('Node type "%s" does not exist', array($nodeType));
             exit(1);
         }
     }
     if ($dryRun) {
         $this->outputLine('Dry run, not committing any changes.');
     }
     foreach ($this->pluginConfigurations as $pluginConfiguration) {
         /** @var NodeCommandControllerPluginInterface $plugin */
         $plugin = $pluginConfiguration['object'];
         $this->outputLine('<b>' . $plugin->getSubCommandShortDescription('repair') . '</b>');
         $this->outputLine();
         $plugin->invokeSubCommand('repair', $this->output, $nodeType, $workspace, $dryRun, $cleanup);
         $this->outputLine();
     }
     $this->outputLine('Node repair finished.');
 }
 /**
  * Returns the current user's personal workspace or null if no user is logged in
  *
  * @return Workspace
  * @api
  */
 public function getPersonalWorkspace()
 {
     $workspaceName = $this->getPersonalWorkspaceName();
     if ($workspaceName !== null) {
         return $this->workspaceRepository->findOneByName($this->getPersonalWorkspaceName());
     }
 }
 /**
  * Creates a big collection of node for performance benchmarking
  * @param string $siteNode
  * @param string $preset
  */
 public function nodesCommand($siteNode, $preset)
 {
     if (!isset($this->presets[$preset])) {
         $this->outputLine('Error: Invalid preset');
         $this->quit(1);
     }
     $preset = $this->presets[$preset];
     /** @var Site $currentSite */
     $currentSite = $this->siteRepository->findOneByNodeName($siteNode);
     if ($currentSite === null) {
         $this->outputLine('Error: No site for exporting found');
         $this->quit(1);
     }
     /** @var ContentContext $contentContext */
     $contentContext = $this->createContext($currentSite, 'live');
     $workspace = 'live';
     if ($this->workspaceRepository->findByName($workspace)->count() === 0) {
         $this->outputLine('Workspace "%s" does not exist', array($workspace));
         $this->quit(1);
     }
     /** @var Node $siteNode */
     $siteNode = $contentContext->getCurrentSiteNode();
     if ($siteNode === null) {
         $this->outputLine('Error: No site root node');
         $this->quit(1);
     }
     $preset = new PresetDefinition($siteNode, $preset);
     $generator = new NodesGenerator($preset);
     $generator->generate();
 }
 /**
  * @test
  */
 public function getUserWorkspaceReturnsTheUsersWorkspaceIfAUserIsLoggedIn()
 {
     $mockUserWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock();
     $mockAccount = $this->getMockBuilder('TYPO3\\Flow\\Security\\Account')->disableOriginalConstructor()->getMock();
     $mockAccount->expects($this->atLeastOnce())->method('getAccountIdentifier')->will($this->returnValue('The UserName'));
     $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAccount')->will($this->returnValue($mockAccount));
     $this->mockWorkspaceRepository->expects($this->atLeastOnce())->method('findOneByName')->with('user-TheUserName')->will($this->returnValue($mockUserWorkspace));
     $this->assertSame($mockUserWorkspace, $this->userService->getUserWorkspace());
 }
 /**
  * @test
  */
 public function getPersonalWorkspaceReturnsTheUsersWorkspaceIfAUserIsLoggedIn()
 {
     $mockUser = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Model\\User')->disableOriginalConstructor()->getMock();
     $mockUserWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock();
     $this->mockUserDomainService->expects($this->atLeastOnce())->method('getCurrentUser')->will($this->returnValue($mockUser));
     $this->mockUserDomainService->expects($this->atLeastOnce())->method('getUserName')->with($mockUser)->will($this->returnValue('TheUserName'));
     $this->mockWorkspaceRepository->expects($this->atLeastOnce())->method('findOneByName')->with('user-TheUserName')->will($this->returnValue($mockUserWorkspace));
     $this->assertSame($mockUserWorkspace, $this->userService->getPersonalWorkspace());
 }
 /**
  * Remove all nodes, workspaces, domains and sites.
  *
  * @return void
  */
 public function pruneAll()
 {
     $sites = $this->siteRepository->findAll();
     $this->nodeDataRepository->removeAll();
     $this->workspaceRepository->removeAll();
     $this->domainRepository->removeAll();
     $this->siteRepository->removeAll();
     foreach ($sites as $site) {
         $this->emitSitePruned($site);
     }
 }
 /**
  * @test
  */
 public function nodePathAvailableForNodeWillReturnFalseIfNodeWithGivenPathExistsAlready()
 {
     $this->workspaceRepository->add(new \TYPO3\TYPO3CR\Domain\Model\Workspace('live'));
     $rootNode = $this->context->getRootNode();
     $fooNode = $rootNode->createNode('foo');
     $fooNode->createNode('bar');
     $bazNode = $rootNode->createNode('baz');
     $this->persistenceManager->persistAll();
     $actualResult = $this->nodeService->nodePathAvailableForNode('/foo/bar', $bazNode);
     $this->assertFalse($actualResult);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->liveWorkspace = new Workspace('live');
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     $this->workspaceRepository->add($this->liveWorkspace);
     $this->persistenceManager->persistAll();
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
 }
 /**
  * Index all nodes.
  *
  * This command (re-)indexes all nodes contained in the content repository and sets the schema beforehand.
  *
  *
  * @param string $workspace
  * @return void
  */
 public function buildCommand($workspace = NULL)
 {
     $this->indexedNodes = 0;
     if ($workspace === NULL) {
         foreach ($this->workspaceRepository->findAll() as $workspace) {
             $this->indexWorkspace($workspace->getName());
         }
     } else {
         $this->indexWorkspace($workspace);
     }
     $this->outputLine('Finished indexing.');
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeTypeManager = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Service\NodeTypeManager::class);
     $this->liveWorkspace = new Workspace('live');
     $this->workspaceRepository = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository::class);
     $this->workspaceRepository->add($this->liveWorkspace);
     $this->persistenceManager->persistAll();
     $this->contextFactory = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Service\ContextFactoryInterface::class);
     $this->context = $this->contextFactory->create(['workspaceName' => 'live']);
     $this->nodeDataRepository = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::class);
 }
 protected function setUpRootNodeAndRepository()
 {
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactory');
     $personalContext = $this->contextFactory->create(array('workspaceName' => $this->currentTestWorkspaceName));
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     if ($this->liveWorkspace === NULL) {
         $this->liveWorkspace = new Workspace('live');
         $this->workspaceRepository->add($this->liveWorkspace);
         $this->workspaceRepository->add(new Workspace($this->currentTestWorkspaceName, $this->liveWorkspace));
         $this->persistenceManager->persistAll();
     }
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $this->rootNode = $personalContext->getNode('/');
     $this->persistenceManager->persistAll();
 }
 protected function setUpRootNodeAndRepository()
 {
     $this->contextFactory = $this->objectManager->get(ContextFactory::class);
     $personalContext = $this->contextFactory->create(array('workspaceName' => $this->currentTestWorkspaceName));
     $this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
     if ($this->liveWorkspace === null) {
         $this->liveWorkspace = new Workspace('live');
         $this->workspaceRepository->add($this->liveWorkspace);
         $this->workspaceRepository->add(new Workspace($this->currentTestWorkspaceName, $this->liveWorkspace));
         $this->persistenceManager->persistAll();
     }
     $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     $this->rootNode = $personalContext->getNode('/');
     $this->persistenceManager->persistAll();
 }
 /**
  * Publishes the whole workspace
  *
  * @param Workspace $workspace
  * @return void
  */
 public function publishWorkspaceAction(Workspace $workspace)
 {
     $liveWorkspace = $this->workspaceRepository->findOneByName('live');
     $workspace->publish($liveWorkspace);
     $this->addFlashMessage('Changes in workspace "%s" have been published', 'Changes published', Message::SEVERITY_OK, array($workspace->getName()), 1412420808);
     $this->redirect('index');
 }
 /**
  * Remove dimensions on nodes "/" and "/sites"
  *
  * This empties the content dimensions on those nodes, so when traversing via the Node API from the root node,
  * the nodes below "/sites" are always reachable.
  *
  * @param string $workspaceName
  * @param boolean $dryRun
  * @return void
  */
 public function removeContentDimensionsFromRootAndSitesNode($workspaceName, $dryRun)
 {
     $workspace = $this->workspaceRepository->findByIdentifier($workspaceName);
     $rootNodes = $this->nodeDataRepository->findByPath('/', $workspace);
     $sitesNodes = $this->nodeDataRepository->findByPath('/sites', $workspace);
     $this->output->outputLine('Checking for root and site nodes with content dimensions set ...');
     /** @var \TYPO3\TYPO3CR\Domain\Model\NodeData $rootNode */
     foreach ($rootNodes as $rootNode) {
         if ($rootNode->getDimensionValues() !== []) {
             if ($dryRun === false) {
                 $rootNode->setDimensions([]);
                 $this->nodeDataRepository->update($rootNode);
                 $this->output->outputLine('Removed content dimensions from root node');
             } else {
                 $this->output->outputLine('Found root node with content dimensions set.');
             }
         }
     }
     /** @var \TYPO3\TYPO3CR\Domain\Model\NodeData $sitesNode */
     foreach ($sitesNodes as $sitesNode) {
         if ($sitesNode->getDimensionValues() !== []) {
             if ($dryRun === false) {
                 $sitesNode->setDimensions([]);
                 $this->nodeDataRepository->update($sitesNode);
                 $this->output->outputLine('Removed content dimensions from node "/sites"');
             } else {
                 $this->output->outputLine('Found node "/sites"');
             }
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     $liveWorkspace = new Workspace("live");
     $this->workspaceRepository->add($liveWorkspace);
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live', 'dimensions' => array('language' => array('en_US'))));
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $this->queryBuilder = $this->objectManager->get('Flowpack\\ElasticSearch\\ContentRepositoryAdaptor\\Eel\\ElasticSearchQueryBuilder');
     $this->nodeIndexCommandController = $this->objectManager->get('Flowpack\\ElasticSearch\\ContentRepositoryAdaptor\\Command\\NodeIndexCommandController');
     $this->queryBuilder->log();
     $this->initializeIndex();
     $this->createNodesForNodeSearchTest();
 }
 public function setUp()
 {
     parent::setUp();
     $this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
     $liveWorkspace = new Workspace('live');
     $this->workspaceRepository->add($liveWorkspace);
     $this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $this->context = $this->contextFactory->create(['workspaceName' => 'live', 'dimensions' => ['language' => ['en_US']], 'targetDimensions' => ['language' => 'en_US']]);
     $rootNode = $this->context->getRootNode();
     $this->siteNode = $rootNode->createNode('welcome', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $this->siteNode->setProperty('title', 'welcome');
     $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     $this->nodeIndexCommandController = $this->objectManager->get(NodeIndexCommandController::class);
     $this->createNodesForNodeSearchTest();
 }
Exemplo n.º 17
0
 /**
  * @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext
  * @return void
  * @throws \TYPO3\Setup\Exception
  */
 public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext)
 {
     $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
     if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
         $this->nodeRepository->removeAll();
         $this->workspaceRepository->removeAll();
         $this->domainRepository->removeAll();
         $this->siteRepository->removeAll();
         $this->persistenceManager->persistAll();
     }
     if (!empty($formValues['packageKey'])) {
         if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) {
             throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
         }
         $packageKey = $formValues['packageKey'];
         $siteName = $formValues['packageKey'];
         $this->packageManager->createPackage($packageKey, NULL, Files::getUnixStylePath(Files::concatenatePaths(array(FLOW3_PATH_PACKAGES, 'Sites'))));
         $this->generatorService->generateSitesXml($packageKey, $siteName);
         $this->generatorService->generateSitesTypoScript($packageKey, $siteName);
         $this->generatorService->generateSitesTemplate($packageKey, $siteName);
         $this->packageManager->activatePackage($packageKey);
     } else {
         $packageKey = $formValues['site'];
     }
     if ($packageKey !== '') {
         try {
             $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext('live');
             $this->nodeRepository->setContext($contentContext);
             $this->siteImportService->importFromPackage($packageKey);
         } catch (\Exception $exception) {
             $finisherContext->cancel();
             $this->flashMessageContainer->addMessage(new \TYPO3\FLOW3\Error\Error(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage())));
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     $liveWorkspace = new Workspace('live');
     $this->workspaceRepository->add($liveWorkspace);
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $this->context = $this->contextFactory->create(['workspaceName' => 'live', 'dimensions' => ['language' => ['en_US']], 'targetDimensions' => ['language' => 'en_US']]);
     $rootNode = $this->context->getRootNode();
     $this->siteNode = $rootNode->createNode('welcome', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $this->siteNode->setProperty('title', 'welcome');
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $this->nodeIndexCommandController = $this->objectManager->get('Flowpack\\ElasticSearch\\ContentRepositoryAdaptor\\Command\\NodeIndexCommandController');
     $this->createNodesForNodeSearchTest();
 }
 /**
  * @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext
  * @return void
  * @throws \TYPO3\Setup\Exception
  */
 public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext)
 {
     $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
     if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
         $this->nodeDataRepository->removeAll();
         $this->workspaceRepository->removeAll();
         $this->domainRepository->removeAll();
         $this->siteRepository->removeAll();
         $this->persistenceManager->persistAll();
     }
     if (!empty($formValues['packageKey'])) {
         if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) {
             throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
         }
         $packageKey = $formValues['packageKey'];
         $siteName = $formValues['siteName'];
         $generatorService = $this->objectManager->get('TYPO3\\Neos\\Kickstarter\\Service\\GeneratorService');
         $generatorService->generateSitePackage($packageKey, $siteName);
     } elseif (!empty($formValues['site'])) {
         $packageKey = $formValues['site'];
     }
     $this->deactivateOtherSitePackages($packageKey);
     $this->packageManager->activatePackage($packageKey);
     if (!empty($packageKey)) {
         try {
             $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
             $this->siteImportService->importFromPackage($packageKey, $contentContext);
         } catch (\Exception $exception) {
             $finisherContext->cancel();
             $this->systemLogger->logException($exception);
             throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864);
         }
     }
 }
 /**
  * Removes all personal workspaces of the given user's account if these workspaces exist. Also removes
  * all possibly existing content of these workspaces.
  *
  * @param string $accountIdentifier Identifier of the user's account
  * @return void
  */
 protected function deleteUserWorkspaces($accountIdentifier)
 {
     $userWorkspace = $this->workspaceRepository->findByIdentifier('user-' . $accountIdentifier);
     if ($userWorkspace instanceof Workspace) {
         $this->publishingService->discardAllNodes($userWorkspace);
         $this->workspaceRepository->remove($userWorkspace);
     }
 }
 /**
  * Removes ownership of all workspaces currently owned by the given user
  *
  * @param User $user The user currently owning workspaces
  * @return void
  */
 protected function removeOwnerFromUsersWorkspaces(User $user)
 {
     /** @var Workspace $workspace */
     foreach ($this->workspaceRepository->findByOwner($user) as $workspace) {
         $workspace->setOwner(null);
         $this->workspaceRepository->update($workspace);
     }
 }
 /**
  * @return \TYPO3\TYPO3CR\Domain\Service\Context
  */
 protected function createContext()
 {
     $workspace = $this->workspaceRepository->findOneByName('live');
     if ($workspace === null) {
         $this->workspaceRepository->add(new Workspace('live'));
     }
     $this->persistenceManager->persistAll();
     return $this->contextFactory->create(array('workspaceName' => 'live', 'invisibleContentShown' => true, 'inaccessibleContentShown' => true));
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeDataRepository = new NodeDataRepository();
     if ($this->liveWorkspace === null) {
         $this->liveWorkspace = new Workspace('live');
         $this->objectManager->get(WorkspaceRepository::class);
         $this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
         $this->workspaceRepository->add($this->liveWorkspace);
         $this->workspaceRepository->add(new Workspace('user-admin', $this->liveWorkspace));
         $this->workspaceRepository->add(new Workspace('live2', $this->liveWorkspace));
         $this->workspaceRepository->add(new Workspace('test', $this->liveWorkspace));
         $this->persistenceManager->persistAll();
     }
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $this->context = $this->contextFactory->create(['workspaceName' => 'live']);
     $this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
     $this->contentDimensionRepository = $this->objectManager->get(ContentDimensionRepository::class);
 }
 public function setUp()
 {
     parent::setUp();
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     $liveWorkspace = new \TYPO3\TYPO3CR\Domain\Model\Workspace("live");
     $this->workspaceRepository->add($liveWorkspace);
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live', 'dimensions' => array('language' => array('de'))));
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $this->queryBuilder = $this->objectManager->get('Flowpack\\ElasticSearch\\ContentRepositoryAdaptor\\Eel\\ElasticSearchQueryBuilder');
     $this->queryBuilder->log();
     // we need to make sure that the index will be prefixed with an unique name. so we add a sleet as it is not
     // possible right now to set the index name
     sleep(4);
     $this->nodeIndexCommandController = $this->objectManager->get('Flowpack\\ElasticSearch\\ContentRepositoryAdaptor\\Command\\NodeIndexCommandController');
     $this->nodeIndexCommandController->buildCommand();
     $this->createNodesForNodeSearchTest();
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeDataRepository = new NodeDataRepository();
     if ($this->liveWorkspace === null) {
         $this->liveWorkspace = new Workspace('live');
         $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
         $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
         $this->workspaceRepository->add($this->liveWorkspace);
         $this->workspaceRepository->add(new Workspace('user-admin', $this->liveWorkspace));
         $this->workspaceRepository->add(new Workspace('live2', $this->liveWorkspace));
         $this->workspaceRepository->add(new Workspace('test', $this->liveWorkspace));
         $this->persistenceManager->persistAll();
     }
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $this->context = $this->contextFactory->create(['workspaceName' => 'live']);
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->contentDimensionRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\ContentDimensionRepository');
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $contentDimensionRepository = $this->objectManager->get(ContentDimensionRepository::class);
     $contentDimensionRepository->setDimensionsConfiguration(array('language' => array('default' => 'mul_ZZ')));
     $this->currentTestWorkspaceName = uniqid('user-');
     $this->contextFactory = $this->objectManager->get(ContextFactory::class);
     if ($this->liveWorkspace === null) {
         $this->liveWorkspace = new Workspace('live');
         $this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
         $this->workspaceRepository->add($this->liveWorkspace);
     }
     $this->workspaceRepository->add(new Workspace($this->currentTestWorkspaceName, $this->liveWorkspace));
     $this->personalContext = $this->contextFactory->create(array('workspaceName' => $this->currentTestWorkspaceName));
     $this->liveContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->rootNodeInLiveWorkspace = $this->liveContext->getNode('/');
     $this->persistenceManager->persistAll();
     $this->rootNodeInPersonalWorkspace = $this->personalContext->getNode('/');
 }
 public function setUp()
 {
     parent::setUp();
     $this->markSkippedIfNodeTypesPackageIsNotInstalled();
     if ($this->liveWorkspace === null) {
         $this->liveWorkspace = new Workspace('live');
         $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
         $this->workspaceRepository->add($this->liveWorkspace);
         $this->workspaceRepository->add(new Workspace('test', $this->liveWorkspace));
         $this->persistenceManager->persistAll();
     }
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $siteImportService = $this->objectManager->get('TYPO3\\Neos\\Domain\\Service\\SiteImportService');
     $siteImportService->importFromFile($this->fixtureFileName, $contentContext);
     $this->persistenceManager->persistAll();
     if ($this->nodeContextPath !== null) {
         $this->node = $this->getNodeWithContextPath($this->nodeContextPath);
     }
 }
 /**
  * Creates an array of workspace names and their respective titles which are possible base workspaces for other
  * workspaces.
  *
  * @param Workspace $excludedWorkspace If set, this workspace will be excluded from the list of returned workspaces
  * @return array
  */
 protected function prepareBaseWorkspaceOptions(Workspace $excludedWorkspace = null)
 {
     $baseWorkspaceOptions = [];
     foreach ($this->workspaceRepository->findAll() as $workspace) {
         /** @var Workspace $workspace */
         if (!$workspace->isPersonalWorkspace() && $workspace !== $excludedWorkspace && ($workspace->isPublicWorkspace() || $workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
             $baseWorkspaceOptions[$workspace->getName()] = $workspace->getTitle();
         }
     }
     return $baseWorkspaceOptions;
 }
 /**
  * @return void
  */
 protected function setUpRootNodeAndRepository()
 {
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactory');
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     $this->workspaceRepository->add(new Workspace('live'));
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->rootNode = $this->context->getNode('/');
     $this->persistenceManager->persistAll();
 }
 /**
  * Imports one or multiple sites from the XML file at $pathAndFilename
  *
  * @param string $pathAndFilename
  * @return Site The imported site
  * @throws UnknownPackageException|InvalidPackageStateException|NeosException
  */
 public function importFromFile($pathAndFilename)
 {
     /** @var Site $importedSite */
     $site = NULL;
     $this->eventEmittingService->withoutEventLog(function () use($pathAndFilename, &$site) {
         $xmlReader = new \XMLReader();
         $xmlReader->open($pathAndFilename, NULL, LIBXML_PARSEHUGE);
         if ($this->workspaceRepository->findOneByName('live') === NULL) {
             $this->workspaceRepository->add(new Workspace('live'));
         }
         $rootNode = $this->contextFactory->create()->getRootNode();
         $this->persistenceManager->persistAll();
         $sitesNode = $rootNode->getNode('/sites');
         if ($sitesNode === NULL) {
             $sitesNode = $rootNode->createSingleNode('sites');
         }
         while ($xmlReader->read()) {
             if ($xmlReader->nodeType != \XMLReader::ELEMENT || $xmlReader->name !== 'site') {
                 continue;
             }
             $isLegacyFormat = $xmlReader->getAttribute('nodeName') !== NULL && $xmlReader->getAttribute('state') === NULL && $xmlReader->getAttribute('siteResourcesPackageKey') === NULL;
             if ($isLegacyFormat) {
                 $site = $this->legacySiteImportService->importSitesFromFile($pathAndFilename);
                 return;
             }
             $site = $this->getSiteByNodeName($xmlReader->getAttribute('siteNodeName'));
             $site->setName($xmlReader->getAttribute('name'));
             $site->setState((int) $xmlReader->getAttribute('state'));
             $siteResourcesPackageKey = $xmlReader->getAttribute('siteResourcesPackageKey');
             if (!$this->packageManager->isPackageAvailable($siteResourcesPackageKey)) {
                 throw new UnknownPackageException(sprintf('Package "%s" specified in the XML as site resources package does not exist.', $siteResourcesPackageKey), 1303891443);
             }
             if (!$this->packageManager->isPackageActive($siteResourcesPackageKey)) {
                 throw new InvalidPackageStateException(sprintf('Package "%s" specified in the XML as site resources package is not active.', $siteResourcesPackageKey), 1303898135);
             }
             $site->setSiteResourcesPackageKey($siteResourcesPackageKey);
             $rootNode = $this->contextFactory->create()->getRootNode();
             // We fetch the workspace to be sure it's known to the persistence manager and persist all
             // so the workspace and site node are persisted before we import any nodes to it.
             $rootNode->getContext()->getWorkspace();
             $this->persistenceManager->persistAll();
             $sitesNode = $rootNode->getNode('/sites');
             if ($sitesNode === NULL) {
                 $sitesNode = $rootNode->createNode('sites');
             }
             $this->nodeImportService->import($xmlReader, $sitesNode->getPath(), dirname($pathAndFilename) . '/Resources');
         }
     });
     if ($site === NULL) {
         throw new NeosException(sprintf('The XML file did not contain a valid site node.'), 1418999522);
     }
     $this->emitSiteImported($site);
     return $site;
 }