Loading Classes/Service/SitemapBuilder.php +17 −12 Original line number Diff line number Diff line Loading @@ -4,7 +4,9 @@ namespace Ttree\Neos\Sitemap\Service; use Tackk\Cartographer\ChangeFrequency; use Tackk\Cartographer\Sitemap; use Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition; use TYPO3\Eel\EelEvaluatorInterface; use TYPO3\Eel\FlowQuery\FlowQuery; use TYPO3\Eel\Utility; use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Http\Request; use TYPO3\Flow\Http\Response; Loading @@ -13,6 +15,7 @@ use TYPO3\Flow\Mvc\ActionRequest; use TYPO3\Flow\Mvc\Controller\Arguments; use TYPO3\Flow\Mvc\Controller\ControllerContext; use TYPO3\Flow\Mvc\Routing\UriBuilder; use TYPO3\Flow\Utility\Arrays; use TYPO3\Neos\Domain\Repository\SiteRepository; use TYPO3\Neos\Service\LinkingService; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; Loading Loading @@ -48,6 +51,12 @@ class SitemapBuilder implements SitemapBuilderInterface { */ protected $uriBuilder; /** * @Flow\Inject * @var EelEvaluatorInterface */ protected $eelEvaluator; /** * @param SitemapDefinition $definiton * @return string Loading @@ -60,19 +69,13 @@ class SitemapBuilder implements SitemapBuilderInterface { $context = $this->createContext('live', $definiton->getSiteNodeName()); $controllerContext = $this->createControllerContext($definiton->getBaseUrl()); foreach ($preset['include'] as $nodeType => $nodeTypeStatus) { if ($nodeTypeStatus !== TRUE) { continue; } $flowQuery = new FlowQuery(array($context->getRootNode())); foreach ($preset['includes'] as $queryLabel => $query) { $nodes = Utility::evaluateEelExpression($query, $this->eelEvaluator, array('node' => $context->getRootNode())); /** @var NodeInterface $node */ foreach ($flowQuery->find(sprintf('[instanceof %s]', $nodeType)) as $node) { foreach ($nodes as $node) { if ($this->needToSkipNode($preset, $node)) { continue; } if (trim($node->getProperty('uriPathSegment')) === '') { continue; } $uri = $this->linkingService->createNodeUri($controllerContext, $node, NULL, 'html', TRUE); $hash = md5($uri); if (isset($processedUri[$hash])) { Loading @@ -93,8 +96,11 @@ class SitemapBuilder implements SitemapBuilderInterface { * @return boolean */ protected function needToSkipNode(array $preset, NodeInterface $node) { if (isset($preset['skip']) && is_array($preset['skip'])) { foreach ($preset['skip'] as $nodeType => $nodeTypeStatus) { if (trim($node->getProperty('uriPathSegment')) === '') { return TRUE; } $skipNodeTypes = Arrays::getValueByPath($preset, 'skipNodeTypes') ?: []; foreach ($skipNodeTypes as $nodeType => $nodeTypeStatus) { if ($nodeTypeStatus !== TRUE) { continue; } Loading @@ -102,7 +108,6 @@ class SitemapBuilder implements SitemapBuilderInterface { return TRUE; } } } return FALSE; } Loading Configuration/Settings.yaml +4 −4 Original line number Diff line number Diff line Loading @@ -3,10 +3,10 @@ Ttree: Sitemap: presets: default: include: 'TYPO3.Neos.NodeTypes:Page': TRUE skip: type: 'normal' includes: 'AllPages': "${q(node).find('[instanceof TYPO3.Neos.NodeTypes:Page]')}" skipNodeTypes: 'TYPO3.Neos:Shortcut': TRUE type: 'single' queueName: 'Default' path: '%FLOW_PATH_DATA%/Web/sitemap.xml' No newline at end of file Loading
Classes/Service/SitemapBuilder.php +17 −12 Original line number Diff line number Diff line Loading @@ -4,7 +4,9 @@ namespace Ttree\Neos\Sitemap\Service; use Tackk\Cartographer\ChangeFrequency; use Tackk\Cartographer\Sitemap; use Ttree\Neos\Sitemap\Domain\Model\SitemapDefinition; use TYPO3\Eel\EelEvaluatorInterface; use TYPO3\Eel\FlowQuery\FlowQuery; use TYPO3\Eel\Utility; use TYPO3\Flow\Annotations as Flow; use TYPO3\Flow\Http\Request; use TYPO3\Flow\Http\Response; Loading @@ -13,6 +15,7 @@ use TYPO3\Flow\Mvc\ActionRequest; use TYPO3\Flow\Mvc\Controller\Arguments; use TYPO3\Flow\Mvc\Controller\ControllerContext; use TYPO3\Flow\Mvc\Routing\UriBuilder; use TYPO3\Flow\Utility\Arrays; use TYPO3\Neos\Domain\Repository\SiteRepository; use TYPO3\Neos\Service\LinkingService; use TYPO3\TYPO3CR\Domain\Model\NodeInterface; Loading Loading @@ -48,6 +51,12 @@ class SitemapBuilder implements SitemapBuilderInterface { */ protected $uriBuilder; /** * @Flow\Inject * @var EelEvaluatorInterface */ protected $eelEvaluator; /** * @param SitemapDefinition $definiton * @return string Loading @@ -60,19 +69,13 @@ class SitemapBuilder implements SitemapBuilderInterface { $context = $this->createContext('live', $definiton->getSiteNodeName()); $controllerContext = $this->createControllerContext($definiton->getBaseUrl()); foreach ($preset['include'] as $nodeType => $nodeTypeStatus) { if ($nodeTypeStatus !== TRUE) { continue; } $flowQuery = new FlowQuery(array($context->getRootNode())); foreach ($preset['includes'] as $queryLabel => $query) { $nodes = Utility::evaluateEelExpression($query, $this->eelEvaluator, array('node' => $context->getRootNode())); /** @var NodeInterface $node */ foreach ($flowQuery->find(sprintf('[instanceof %s]', $nodeType)) as $node) { foreach ($nodes as $node) { if ($this->needToSkipNode($preset, $node)) { continue; } if (trim($node->getProperty('uriPathSegment')) === '') { continue; } $uri = $this->linkingService->createNodeUri($controllerContext, $node, NULL, 'html', TRUE); $hash = md5($uri); if (isset($processedUri[$hash])) { Loading @@ -93,8 +96,11 @@ class SitemapBuilder implements SitemapBuilderInterface { * @return boolean */ protected function needToSkipNode(array $preset, NodeInterface $node) { if (isset($preset['skip']) && is_array($preset['skip'])) { foreach ($preset['skip'] as $nodeType => $nodeTypeStatus) { if (trim($node->getProperty('uriPathSegment')) === '') { return TRUE; } $skipNodeTypes = Arrays::getValueByPath($preset, 'skipNodeTypes') ?: []; foreach ($skipNodeTypes as $nodeType => $nodeTypeStatus) { if ($nodeTypeStatus !== TRUE) { continue; } Loading @@ -102,7 +108,6 @@ class SitemapBuilder implements SitemapBuilderInterface { return TRUE; } } } return FALSE; } Loading
Configuration/Settings.yaml +4 −4 Original line number Diff line number Diff line Loading @@ -3,10 +3,10 @@ Ttree: Sitemap: presets: default: include: 'TYPO3.Neos.NodeTypes:Page': TRUE skip: type: 'normal' includes: 'AllPages': "${q(node).find('[instanceof TYPO3.Neos.NodeTypes:Page]')}" skipNodeTypes: 'TYPO3.Neos:Shortcut': TRUE type: 'single' queueName: 'Default' path: '%FLOW_PATH_DATA%/Web/sitemap.xml' No newline at end of file