当前位置: 首页>>代码示例>>PHP>>正文


PHP Service\Context类代码示例

本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Service\Context的典型用法代码示例。如果您正苦于以下问题:PHP Context类的具体用法?PHP Context怎么用?PHP Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createNodeFromTemplateUsesWorkspacesOfContext

 /**
  * @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');
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:12,代码来源:NodeTemplatesTest.php

示例2: filterNodeByContext

 /**
  * Filter a node by the current context.
  * Will either return the node or NULL if it is not permitted in current context.
  *
  * @param NodeInterface $node
  * @param Context $context
  * @return \TYPO3\TYPO3CR\Domain\Model\Node|NULL
  */
 protected function filterNodeByContext(NodeInterface $node, Context $context)
 {
     if (!$context->isRemovedContentShown() && $node->isRemoved()) {
         return NULL;
     }
     if (!$context->isInvisibleContentShown() && !$node->isVisible()) {
         return NULL;
     }
     if (!$context->isInaccessibleContentShown() && !$node->isAccessible()) {
         return NULL;
     }
     return $node;
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:21,代码来源:NodeFactory.php

示例3: setUp

 public function setUp()
 {
     $this->convertEmailLinks = $this->getAccessibleMock('Networkteam\\Neos\\MailObfuscator\\Typoscript\\ConvertEmailLinksImplementation', array('getValue'), array(), '', FALSE);
     $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getWorkspaceName')->will($this->returnValue('live'));
     $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock();
     $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext));
     $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock();
     $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue(array('node' => $this->mockNode)));
     $this->convertEmailLinks->_set('tsRuntime', $this->mockTsRuntime);
     $this->convertEmailLinks->_set('linkNameConverter', new \Networkteam\Neos\MailObfuscator\String\Converter\RewriteAtCharConverter());
     $this->convertEmailLinks->_set('mailToHrefConverter', new \Networkteam\Neos\MailObfuscator\String\Converter\Mailto2HrefObfuscatingConverter());
     srand(10);
 }
开发者ID:ComiR,项目名称:Networkteam.Neos.MailObfuscator,代码行数:14,代码来源:ConvertEmailLinksImplementationTest.php

示例4: setUp

 public function setUp()
 {
     $this->siteNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
     $this->firstLevelNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
     $this->secondLevelNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface');
     $this->siteNode->expects($this->any())->method('getPath')->will($this->returnValue('/site'));
     $this->siteNode->expects($this->any())->method('getChildNodes')->will($this->returnValue(array($this->firstLevelNode)));
     $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->any())->method('getCurrentSiteNode')->will($this->returnValue($this->siteNode));
     $this->firstLevelNode->expects($this->any())->method('getParent')->will($this->returnValue($this->siteNode));
     $this->firstLevelNode->expects($this->any())->method('getPath')->will($this->returnValue('/site/first'));
     $this->secondLevelNode->expects($this->any())->method('getParent')->will($this->returnValue($this->siteNode));
     $this->secondLevelNode->expects($this->any())->method('getPath')->will($this->returnValue('/site/first/second'));
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:14,代码来源:ParentOperationTest.php

示例5: dimensionsAreMatchingTargetDimensionValues

 /**
  * Internal method
  *
  * The dimension value of this node has to match the current target dimension value (must be higher in priority or equal)
  *
  * @return boolean
  */
 public function dimensionsAreMatchingTargetDimensionValues()
 {
     $dimensions = $this->getDimensions();
     $contextDimensions = $this->context->getDimensions();
     foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
         if (!isset($dimensions[$dimensionName])) {
             if ($targetDimensionValue === null) {
                 continue;
             } else {
                 return false;
             }
         } elseif ($targetDimensionValue === null && $dimensions[$dimensionName] === array()) {
             continue;
         } elseif (!in_array($targetDimensionValue, $dimensions[$dimensionName], true)) {
             $contextDimensionValues = $contextDimensions[$dimensionName];
             $targetPositionInContext = array_search($targetDimensionValue, $contextDimensionValues, true);
             $nodePositionInContext = min(array_map(function ($value) use($contextDimensionValues) {
                 return array_search($value, $contextDimensionValues, true);
             }, $dimensions[$dimensionName]));
             $val = $targetPositionInContext !== false && $nodePositionInContext !== false && $targetPositionInContext >= $nodePositionInContext;
             if ($val === false) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:hhoechtl,项目名称:neos-development-collection,代码行数:34,代码来源:Node.php

示例6: setUp

 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();
 }
开发者ID:robertlemke,项目名称:Flowpack.ElasticSearch.ContentRepositoryAdaptor,代码行数:16,代码来源:ElasticSearchQueryTest.php

示例7: setUp

 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();
 }
开发者ID:kdambekalns,项目名称:Flowpack.ElasticSearch.ContentRepositoryAdaptor,代码行数:16,代码来源:ElasticSearchQueryTest.php

示例8: findByProperties

 /**
  * Search all properties for given $term
  *
  * TODO: Implement a better search when Flow offer the possibility
  *
  * @param string $term
  * @param array $searchNodeTypes
  * @param Context $context
  * @param NodeInterface $startingPoint
  * @return array <\TYPO3\TYPO3CR\Domain\Model\NodeInterface>
  */
 public function findByProperties($term, array $searchNodeTypes, Context $context, NodeInterface $startingPoint = null)
 {
     if (strlen($term) === 0) {
         throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
     }
     $searchResult = array();
     $nodeTypeFilter = implode(',', $searchNodeTypes);
     $nodeDataRecords = $this->nodeDataRepository->findByProperties($term, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $startingPoint ? $startingPoint->getPath() : null);
     foreach ($nodeDataRecords as $nodeData) {
         $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
         if ($node !== null) {
             $searchResult[$node->getPath()] = $node;
         }
     }
     return $searchResult;
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:27,代码来源:NodeSearchService.php

示例9: addHeadersInLiveWorkspaceAndCachedResponseAddsSiteToken

 /**
  * @test
  */
 public function addHeadersInLiveWorkspaceAndCachedResponseAddsSiteToken()
 {
     $this->mockContext->expects($this->any())->method('getWorkspaceName')->willReturn('live');
     $this->mockTokenStorage->expects($this->any())->method('getToken')->willReturn('RandomSiteToken');
     $this->mockResponse->expects($this->at(0))->method('setHeader')->with('X-Site', 'RandomSiteToken');
     $this->service->addHeaders($this->mockRequest, $this->mockResponse, $this->mockController);
 }
开发者ID:christophlehmann,项目名称:MOC.Varnish,代码行数:10,代码来源:CacheControlServiceTest.php

示例10: __construct

 /**
  * Creates a new Content Context object.
  *
  * NOTE: This is for internal use only, you should use the ContextFactory for creating Context instances.
  *
  * @param string $workspaceName Name of the current workspace
  * @param \DateTimeInterface $currentDateTime The current date and time
  * @param array $dimensions Array of dimensions with array of ordered values
  * @param array $targetDimensions Array of dimensions used when creating / modifying content
  * @param boolean $invisibleContentShown If invisible content should be returned in query results
  * @param boolean $removedContentShown If removed content should be returned in query results
  * @param boolean $inaccessibleContentShown If inaccessible content should be returned in query results
  * @param Site $currentSite The current Site object
  * @param Domain $currentDomain The current Domain object
  * @see ContextFactoryInterface
  */
 public function __construct($workspaceName, \DateTimeInterface $currentDateTime, array $dimensions, array $targetDimensions, $invisibleContentShown, $removedContentShown, $inaccessibleContentShown, Site $currentSite = null, Domain $currentDomain = null)
 {
     parent::__construct($workspaceName, $currentDateTime, $dimensions, $targetDimensions, $invisibleContentShown, $removedContentShown, $inaccessibleContentShown);
     $this->currentSite = $currentSite;
     $this->currentDomain = $currentDomain;
     $this->targetDimensions = $targetDimensions;
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:23,代码来源:ContentContext.php

示例11: createNodeForVariant

 /**
  * 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);
 }
开发者ID:rderidder,项目名称:neos-development-collection,代码行数:14,代码来源:Node.php

示例12: sortByDateTimeDescending

 /**
  * @test
  */
 public function sortByDateTimeDescending()
 {
     $nodesToSort = [$this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), array())];
     $correctOrder = [$this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), array())];
     $flowQuery = new \TYPO3\Eel\FlowQuery\FlowQuery($nodesToSort);
     $operation = new SortOperation();
     $operation->evaluate($flowQuery, ['_lastPublicationDateTime', 'DESC']);
     $this->assertEquals($correctOrder, $flowQuery->getContext());
 }
开发者ID:johannessteu,项目名称:neos-development-collection,代码行数:12,代码来源:SortOperationTest.php

示例13: findOrCreateMetaDataRootNode

 /**
  * @param Context $context
  * @return NodeInterface
  * @throws NodeTypeNotFoundException
  * @throws NodeConfigurationException
  */
 public function findOrCreateMetaDataRootNode(Context $context)
 {
     if ($this->metaDataRootNode instanceof NodeInterface) {
         return $this->metaDataRootNode;
     }
     $metaDataRootNodeData = $this->metaDataRepository->findOneByPath('/' . MetaDataRepository::METADATA_ROOT_NODE_NAME, $context->getWorkspace());
     if ($metaDataRootNodeData !== null) {
         $metaDataRootNode = $this->nodeFactory->createFromNodeData($metaDataRootNodeData, $context);
         return $metaDataRootNode;
     }
     $nodeTemplate = new NodeTemplate();
     $nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType('unstructured'));
     $nodeTemplate->setName(MetaDataRepository::METADATA_ROOT_NODE_NAME);
     $context = $this->contextFactory->create(['workspaceName' => 'live']);
     $rootNode = $context->getRootNode();
     $this->metaDataRootNode = $rootNode->createNodeFromTemplate($nodeTemplate);
     $this->persistenceManager->persistAll();
     return $this->metaDataRootNode;
 }
开发者ID:neos,项目名称:metadata-contentrepositoryadapter,代码行数:25,代码来源:NodeService.php

示例14: setUpRootNodeAndRepository

 /**
  * @return void
  */
 protected function setUpRootNodeAndRepository()
 {
     $this->contextFactory = $this->objectManager->get(ContextFactory::class);
     $this->context = $this->contextFactory->create(array('workspaceName' => 'live'));
     $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     $this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
     $this->workspaceRepository->add(new Workspace('live'));
     $this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
     $this->rootNode = $this->context->getNode('/');
     $this->persistenceManager->persistAll();
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:14,代码来源:NodeDataExportServiceTest.php

示例15: setUpRootNodeAndRepository

 /**
  * @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();
 }
开发者ID:simonschaufi,项目名称:neos-development-collection,代码行数:14,代码来源:NodeDataExportServiceTest.php


注:本文中的TYPO3\TYPO3CR\Domain\Service\Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。