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


PHP NodeDataRepository::findNodesByRelatedEntities方法代码示例

本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::findNodesByRelatedEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeDataRepository::findNodesByRelatedEntities方法的具体用法?PHP NodeDataRepository::findNodesByRelatedEntities怎么用?PHP NodeDataRepository::findNodesByRelatedEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository的用法示例。


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

示例1: removeUnusedImageVariant

 /**
  * Removes unused ImageVariants after a Node property changes to a different ImageVariant.
  * This is triggered via the nodePropertyChanged event.
  *
  * Note: This method it triggered by the "nodePropertyChanged" signal, @see \TYPO3\TYPO3CR\Domain\Model\Node::emitNodePropertyChanged()
  *
  * @param NodeInterface $node the affected node
  * @param string $propertyName name of the property that has been changed/added
  * @param mixed $oldValue the property value before it was changed or NULL if the property is new
  * @param mixed $value the new property value
  * @return void
  */
 public function removeUnusedImageVariant(NodeInterface $node, $propertyName, $oldValue, $value)
 {
     if ($oldValue === $value || !$oldValue instanceof ImageVariant) {
         return;
     }
     $identifier = $this->persistenceManager->getIdentifierByObject($oldValue);
     $results = $this->nodeDataRepository->findNodesByRelatedEntities(array(ImageVariant::class => [$identifier]));
     // This case shouldn't happen as the query will usually find at least the node that triggered this call, still if there is no relation we can remove the ImageVariant.
     if ($results === []) {
         $this->assetRepository->remove($oldValue);
         return;
     }
     // If the result contains exactly the node that got a new ImageVariant assigned then we are safe to remove the asset here.
     if ($results === [$node->getNodeData()]) {
         $this->assetRepository->remove($oldValue);
     }
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:29,代码来源:ImageVariantGarbageCollector.php

示例2: findNodesByRelatedEntitiesFindsExistingNodeWithMatchingEntityProperty

 /**
  * @test
  */
 public function findNodesByRelatedEntitiesFindsExistingNodeWithMatchingEntityProperty()
 {
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNode('test', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithEntities'));
     $testImage = new Image();
     $this->persistenceManager->add($testImage);
     $newNode->setProperty('image', $testImage);
     $this->persistenceManager->persistAll();
     $relationMap = array('TYPO3\\Flow\\Tests\\Functional\\Persistence\\Fixtures\\Image' => array($this->persistenceManager->getIdentifierByObject($testImage)));
     $result = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
     $this->assertCount(1, $result);
 }
开发者ID:simonschaufi,项目名称:neos-development-collection,代码行数:15,代码来源:NodeDataRepositoryTest.php

示例3: deleteAction

 /**
  * Delete an asset
  *
  * @param \TYPO3\Media\Domain\Model\Asset $asset
  * @return void
  */
 public function deleteAction(\TYPO3\Media\Domain\Model\Asset $asset)
 {
     $relationMap = [];
     $relationMap[TypeHandling::getTypeForValue($asset)] = array($this->persistenceManager->getIdentifierByObject($asset));
     if ($asset instanceof \TYPO3\Media\Domain\Model\Image) {
         foreach ($asset->getVariants() as $variant) {
             $type = TypeHandling::getTypeForValue($variant);
             if (!isset($relationMap[$type])) {
                 $relationMap[$type] = [];
             }
             $relationMap[$type][] = $this->persistenceManager->getIdentifierByObject($variant);
         }
     }
     $relatedNodes = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
     if (count($relatedNodes) > 0) {
         $this->addFlashMessage('Asset could not be deleted, because there are still Nodes using it.', '', Message::SEVERITY_WARNING, array(), 1412422767);
         $this->redirect('index');
     }
     // FIXME: Resources are not deleted, because we cannot be sure that the resource isn't used anywhere else.
     $this->assetRepository->remove($asset);
     $this->addFlashMessage(sprintf('Asset "%s" has been deleted.', $asset->getLabel()), null, null, array(), 1412375050);
     $this->redirect('index');
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:29,代码来源:AssetController.php

示例4: getRelatedNodes

 /**
  * @param \TYPO3\Media\Domain\Model\Asset $asset
  * @return array
  */
 protected function getRelatedNodes(\TYPO3\Media\Domain\Model\Asset $asset)
 {
     $relationMap = [];
     $relationMap[TypeHandling::getTypeForValue($asset)] = [$this->persistenceManager->getIdentifierByObject($asset)];
     if ($asset instanceof \TYPO3\Media\Domain\Model\Image) {
         foreach ($asset->getVariants() as $variant) {
             $type = TypeHandling::getTypeForValue($variant);
             if (!isset($relationMap[$type])) {
                 $relationMap[$type] = [];
             }
             $relationMap[$type][] = $this->persistenceManager->getIdentifierByObject($variant);
         }
     }
     return $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
 }
开发者ID:sbruggmann,项目名称:neos-development-collection,代码行数:19,代码来源:AssetController.php


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