php TYPO3-TYPO3CR-Domain-Service-ContextFactoryInterface类(方法)实例源码

下面列出了php TYPO3-TYPO3CR-Domain-Service-ContextFactoryInterface 类(方法)源码代码实例,从而了解它的用法。

作者:johannesste    项目:neos-development-collectio   
/**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     $domainRepository = $this->objectManager->get(DomainRepository::class);
     $siteRepository = $this->objectManager->get(SiteRepository::class);
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $contextProperties = array('workspaceName' => 'live');
     $contentContext = $this->contextFactory->create($contextProperties);
     $siteImportService = $this->objectManager->get(SiteImportService::class);
     $siteImportService->importFromFile(__DIR__ . '/../Fixtures/NodeStructure.xml', $contentContext);
     $this->persistenceManager->persistAll();
     $currentDomain = $domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $siteRepository->findFirst();
     }
     $contentContext = $this->contextFactory->create($contextProperties);
     $this->contentContext = $contentContext;
     $this->propertyMapper = $this->objectManager->get(PropertyMapper::class);
     $this->baseNode = $this->contentContext->getCurrentSiteNode()->getNode('home');
     $this->linkingService = $this->objectManager->get(LinkingService::class);
     /** @var $requestHandler FunctionalTestRequestHandler */
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $this->controllerContext = new ControllerContext(new ActionRequest($requestHandler->getHttpRequest()), $requestHandler->getHttpResponse(), new Arguments(array()), new UriBuilder());
 }

作者:hlube    项目:neos-development-collectio   
/**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeDataRepository = new \TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository();
     $this->contextFactory = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Service\ContextFactoryInterface::class);
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->nodeTypeManager = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Service\NodeTypeManager::class);
     $this->contentDimensionRepository = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Repository\ContentDimensionRepository::class);
     $this->workspaceRepository = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository::class);
     $this->nodeService = $this->objectManager->get(NodeService::class);
 }

作者:mgoldbec    项目:neos-development-collectio   
public function setUp()
 {
     parent::setUp();
     $this->markSkippedIfNodeTypesPackageIsNotInstalled();
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->siteImportService = $this->objectManager->get('TYPO3\\Neos\\Domain\\Service\\SiteImportService');
     $this->siteExportService = $this->objectManager->get('TYPO3\\Neos\\Domain\\Service\\SiteExportService');
     $this->importedSite = $this->siteImportService->importFromFile(__DIR__ . '/' . $this->fixtureFileName, $contentContext);
     $this->persistenceManager->persistAll();
 }

作者:robertlemk    项目:neos-development-collectio   
/**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->nodeDataRepository = new NodeDataRepository();
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
     $workspace = new Workspace('live');
     $this->objectManager->get(WorkspaceRepository::class)->add($workspace);
     $this->persistenceManager->persistAll();
     $context = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->rootNode = $context->getRootNode();
 }

作者:hhoecht    项目:neos-development-collectio   
/**
  * @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);
 }

作者:simonschauf    项目:neos-development-collectio   
/**
  * @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');
 }

作者:robertlemk    项目:neos-development-collectio   
public function setUp()
 {
     parent::setUp();
     $this->markSkippedIfNodeTypesPackageIsNotInstalled();
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $siteImportService = $this->objectManager->get(SiteImportService::class);
     $siteImportService->importFromFile(__DIR__ . '/' . $this->fixtureFileName, $contentContext);
     $this->persistenceManager->persistAll();
     if ($this->nodeContextPath !== null) {
         $this->node = $this->getNodeWithContextPath($this->nodeContextPath);
     }
 }

作者:johannesste    项目:neos-development-collectio   
public function setUp()
 {
     parent::setUp();
     $this->router->setRoutesConfiguration(null);
     $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     $domainRepository = $this->objectManager->get(DomainRepository::class);
     $siteRepository = $this->objectManager->get(SiteRepository::class);
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $contextProperties = array('workspaceName' => 'live');
     $contentContext = $this->contextFactory->create($contextProperties);
     $siteImportService = $this->objectManager->get(SiteImportService::class);
     $siteImportService->importFromFile(__DIR__ . '/../../Fixtures/NodeStructure.xml', $contentContext);
     $this->persistenceManager->persistAll();
     /** @var Domain $currentDomain */
     $currentDomain = $domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $siteRepository->findFirst();
     }
     $contentContext = $this->contextFactory->create($contextProperties);
     $this->contentContext = $contentContext;
     $this->propertyMapper = $this->objectManager->get(PropertyMapper::class);
     $this->viewHelper = new NodeViewHelper();
     /** @var $requestHandler FunctionalTestRequestHandler */
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $httpRequest = $requestHandler->getHttpRequest();
     $httpRequest->setBaseUri(new Uri('http://neos.test/'));
     $controllerContext = new ControllerContext(new ActionRequest($httpRequest), $requestHandler->getHttpResponse(), new Arguments(array()), new UriBuilder());
     $this->inject($this->viewHelper, 'controllerContext', $controllerContext);
     $typoScriptObject = $this->getAccessibleMock(TemplateImplementation::class, array('dummy'), array(), '', false);
     $this->tsRuntime = new Runtime(array(), $controllerContext);
     $this->tsRuntime->pushContextArray(array('documentNode' => $this->contentContext->getCurrentSiteNode()->getNode('home'), 'alternativeDocumentNode' => $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission')));
     $this->inject($typoScriptObject, 'tsRuntime', $this->tsRuntime);
     /** @var AbstractTemplateView|\PHPUnit_Framework_MockObject_MockObject $mockView */
     $mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false);
     $mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($typoScriptObject));
     $viewHelperVariableContainer = new ViewHelperVariableContainer();
     $viewHelperVariableContainer->setView($mockView);
     $this->inject($this->viewHelper, 'viewHelperVariableContainer', $viewHelperVariableContainer);
     $templateVariableContainer = new TemplateVariableContainer(array());
     $this->inject($this->viewHelper, 'templateVariableContainer', $templateVariableContainer);
     $this->viewHelper->setRenderChildrenClosure(function () use($templateVariableContainer) {
         $linkedNode = $templateVariableContainer->get('linkedNode');
         return $linkedNode !== null ? $linkedNode->getLabel() : '';
     });
     $this->viewHelper->initialize();
 }

作者:johannesste    项目:neos-development-collectio   
/**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $workspaceRepository = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository::class);
     $workspaceRepository->add(new Workspace('live'));
     $this->persistenceManager->persistAll();
     $this->contextFactory = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Service\ContextFactoryInterface::class);
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
     $siteImportService = $this->objectManager->get(\TYPO3\Neos\Domain\Service\SiteImportService::class);
     $siteImportService->importFromFile(__DIR__ . '/Fixtures/SortableNodes.xml', $this->context);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->inject($this->contextFactory, 'contextInstances', array());
     // The context is not important here, just a quick way to get a (live) workspace
     //        $context = $this->contextFactory->create();
     $this->nodeDataRepository = $this->objectManager->get(\TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::class);
 }

作者:johannesste    项目:Flowpack.ElasticSearch.ContentRepositoryAdapto   
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();
 }

作者:mgoldbec    项目:neos-development-collectio   
/**
  * Add the current node and all parent identifiers to be used for cache entry tagging
  *
  * @Flow\Before("method(TYPO3\Flow\Mvc\Routing\RouterCachingService->extractUuids())")
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function addCurrentNodeIdentifier(JoinPointInterface $joinPoint)
 {
     $values = $joinPoint->getMethodArgument('values');
     if (!isset($values['node']) || strpos($values['node'], '@') === false) {
         return;
     }
     // Build context explicitly without authorization checks because the security context isn't available yet
     // anyway and any Entity Privilege targeted on Workspace would fail at this point:
     $this->securityContext->withoutAuthorizationChecks(function () use($joinPoint, $values) {
         $contextPathPieces = NodePaths::explodeContextPath($values['node']);
         $context = $this->contextFactory->create(['workspaceName' => $contextPathPieces['workspaceName'], 'dimensions' => $contextPathPieces['dimensions'], 'invisibleContentShown' => true]);
         $node = $context->getNode($contextPathPieces['nodePath']);
         if (!$node instanceof NodeInterface) {
             return;
         }
         $values['node-identifier'] = $node->getIdentifier();
         $node = $node->getParent();
         $values['node-parent-identifier'] = array();
         while ($node !== null) {
             $values['node-parent-identifier'][] = $node->getIdentifier();
             $node = $node->getParent();
         }
         $joinPoint->setMethodArgument('values', $values);
     });
 }

作者:radmiraa    项目:TYPO3.TYPO3C   
/**
  * @test
  */
 public function createNodeFromTemplateUsesWorkspacesOfContext()
 {
     $nodeTemplate = $this->generateBasicNodeTemplate();
     $this->context = $this->contextFactory->create(array('workspaceName' => 'user1'));
     $rootNode = $this->context->getNode('/');
     $node = $rootNode->createNodeFromTemplate($nodeTemplate, 'just-a-node');
     $workspace = $node->getWorkspace();
     $this->assertEquals('user1', $workspace->getName(), 'Node should be created in workspace of context');
 }

作者:reinis-zumberg    项目:neos-development-collectio   
/**
  * Create a context object based on the context stored in the node path
  *
  * @param string $contextArguments
  * @return Context
  */
 protected function getContext($contextArguments)
 {
     $contextConfiguration = explode(';', $contextArguments);
     $workspaceName = array_shift($contextConfiguration);
     $dimensionConfiguration = explode('&', array_shift($contextConfiguration));
     $dimensions = array();
     foreach ($contextConfiguration as $dimension) {
         list($dimensionName, $dimensionValue) = explode('=', $dimension);
         $dimensions[$dimensionName] = explode(',', $dimensionValue);
     }
     $context = $this->contextFactory->create(array('workspaceName' => $workspaceName, 'dimensions' => $dimensions, 'invisibleContentShown' => true));
     return $context;
 }

作者:keen-vantag    项目:BuJitsuDo.Ap   
/**
  * @return string
  */
 public final function getList()
 {
     $context = $this->contextFactory->create(['workspaceName' => 'live']);
     $flowQuery = new FlowQuery([$context->getRootNode()]);
     $events = $flowQuery->find('[instanceof Nieuwenhuizen.BuJitsuDo:Article]')->get();
     $result['articles'] = [];
     usort($events, function (NodeInterface $a, NodeInterface $b) {
         return $this->sortNodesSelection($a, $b, 'publicationDate', false);
     });
     foreach ($events as $event) {
         $result['articles'][] = $this->buildSingleItemJson($event);
     }
     return $result;
 }

作者:neo    项目:Neos.NeosI   
/**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return NodeData
  */
 public function execute(NodeData $node)
 {
     $node = $this->nodeFactory->createFromNodeData($node, $this->contextFactory->create(array('workspaceName' => $node->getWorkspace()->getName(), 'invisibleContentShown' => true, 'inaccessibleContentShown' => true)));
     if (!$node) {
         return;
     }
     $column0 = $node->getPrimaryChildNode();
     if (!$column0) {
         return;
     }
     foreach ($column0->getChildNodes() as $childNode) {
         $node = $childNode->copyAfter($node, NodePaths::generateRandomNodeName());
     }
     return $node;
 }

作者:mgoldbec    项目:neos-development-collectio   
/**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery The FlowQuery object
  * @param array $arguments The arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || !is_array($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('context() requires an array argument of context properties', 1398030427);
     }
     $output = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $contextProperties = $contextNode->getContext()->getProperties();
         $modifiedContext = $this->contextFactory->create(array_merge($contextProperties, $arguments[0]));
         $nodeInModifiedContext = $modifiedContext->getNodeByIdentifier($contextNode->getIdentifier());
         if ($nodeInModifiedContext !== null) {
             $output[$nodeInModifiedContext->getPath()] = $nodeInModifiedContext;
         }
     }
     $flowQuery->setContext(array_values($output));
 }

作者:radmiraa    项目:neos-development-collectio   
/**
  * @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);
         }
     }
 }

作者:hhoecht    项目:neos-development-collectio   
/**
  * @test
  */
 public function setDimensionsToEMptyArrayRemovesDimensions()
 {
     $siteImportService = $this->objectManager->get(SiteImportService::class);
     $siteImportService->importFromFile(__DIR__ . '/../Fixtures/NodeStructure.xml', $this->context);
     $this->persistenceManager->persistAll();
     $this->inject($this->contextFactory, 'contextInstances', []);
     $nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     // The context is not important here, just a quick way to get a (live) workspace
     $context = $this->contextFactory->create();
     // The identifier comes from the Fixture.
     /** @var \TYPO3\TYPO3CR\Domain\Model\NodeData $resultingNodeData */
     $resultingNodeData = $nodeDataRepository->findOneByIdentifier('9fa376af-a1b8-83ac-bedc-9ad83c8598bc', $context->getWorkspace(true), []);
     $this->assertNotEmpty($resultingNodeData->getDimensions());
     $resultingNodeData->setDimensions([]);
     $nodeDataRepository->update($resultingNodeData);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->inject($this->contextFactory, 'contextInstances', []);
     // The context is not important here, just a quick way to get a (live) workspace
     $context = $this->contextFactory->create();
     // The identifier comes from the Fixture.
     /** @var \TYPO3\TYPO3CR\Domain\Model\NodeData $resultingNodeData */
     $resultingNodeData = $nodeDataRepository->findOneByIdentifier('9fa376af-a1b8-83ac-bedc-9ad83c8598bc', $context->getWorkspace(true), []);
     $this->assertEmpty($resultingNodeData->getDimensions());
 }

作者:rderidde    项目:neos-development-collectio   
/**
  * Create a node for the given NodeData, given that it is a variant of the current node
  *
  * @param NodeData $nodeData
  * @return Node
  */
 protected function createNodeForVariant($nodeData)
 {
     $contextProperties = $this->context->getProperties();
     $contextProperties['dimensions'] = $nodeData->getDimensionValues();
     unset($contextProperties['targetDimensions']);
     $adjustedContext = $this->contextFactory->create($contextProperties);
     return $this->nodeFactory->createFromNodeData($nodeData, $adjustedContext);
 }

作者:radmiraa    项目:neos-development-collectio   
/**
  * Flush the node changes and reset the persistence manager and node data registry
  *
  * @return void
  */
 public function flushNodeChanges()
 {
     $nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $nodeDataRepository->flushNodeRegistry();
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->contextFactory->reset();
 }


问题


面经


文章

微信
公众号

扫码关注公众号