/** * @return void */ protected function initializeSystemNodes() { $contentContext = $this->getContentContext(true); $flowQuery = new FlowQuery([$contentContext->getNode($this->rootNodePath)]); $this->systemNodeIdentifiers = []; foreach ($flowQuery->find('[instanceof Nezaniel.SystemNodes:SystemNode]')->get() as $systemNode) { $this->initializeSystemNode($systemNode); } $this->cache->set('systemNodeIdentifiers', $this->systemNodeIdentifiers); }
/** * @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; }
/** * Repair votes action * * Compare number of votes between nodes and vote log and repair, if not dryRun * * @param boolean $dryRun Don't do anything, but report actions * @return string */ public function repairCommand($dryRun = TRUE) { if ($dryRun) { echo "Dry run, not making any changes\n"; } $q = new FlowQuery(array($this->context->getRootNode())); $answerNodes = $q->find('[instanceof Sfi.Encult:Answer]')->get(); foreach ($answerNodes as $answerNode) { /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */ $queryBuilder = $this->entityManager->createQueryBuilder(); $nodes = $queryBuilder->select('v')->from('Sfi\\Encult\\Domain\\Model\\Vote', 'v')->andWhere('v.answerIdentifier = :answerIdentifier')->setParameters(array('answerIdentifier' => $answerNode->getIdentifier()))->getQuery()->getArrayResult(); $dbCount = count($nodes); $crCount = $answerNode->getProperty('voteCount'); $path = $answerNode->getPath(); if ($dbCount !== $crCount) { echo "Found mistake for {$path} (db: {$dbCount} vs. cr: {$crCount})\n"; if (!$dryRun) { echo "Fixed\n"; $answerNode->setProperty('voteCount', $dbCount); } } } return "Done!\n"; }
protected function getNewsByOriginalId($id) { $q = new FlowQuery(array($this->context->getRootNode())); return $q->find('[instanceof Sfi.Kateheo:News]')->filter('[originalIdentifier = "' . $id . '"]')->get(0); }
/** * @test */ public function findByNodeWithInstanceofFilterAppliesAdditionalAttributeFilter() { $q = new FlowQuery(array($this->node)); $foundNodes = $q->find('[instanceof TYPO3.TYPO3CR.Testing:Text][text*="Twitter"]')->get(); $this->assertCount(1, $foundNodes); }
/** * Gets a storage folder by type, and creates it if needed * * @param string $nodeTypeName * @param NodeInterface $rootNode * @return NodeInterface */ protected function getStorageFolder($nodeTypeName, NodeInterface $rootNode) { $query = new FlowQuery([$rootNode]); $storageFolder = $query->find('[instanceof ' . $nodeTypeName . ']')->get(0); if (!$storageFolder instanceof NodeInterface) { $storageFolder = $rootNode->createNode(uniqid('node-'), $this->nodeTypeManager->getNodeType($nodeTypeName)); } return $storageFolder; }