Skip to content

Instantly share code, notes, and snippets.

@daniellienert
Created March 29, 2020 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniellienert/7ad22f8e337177b257ae9a8f4cfab265 to your computer and use it in GitHub Desktop.
Save daniellienert/7ad22f8e337177b257ae9a8f4cfab265 to your computer and use it in GitHub Desktop.
Neos: Adjust Reference Selector Starting Point
<?php
namespace Your\Vendor\Aop\Aspect;
/*
* (c) 2018 punkt.de GmbH - Karlsruhe, Germany - http://punkt.de
* All rights reserved.
*/
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Model\NodeType;
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\ObjectManagement\Exception\UnknownObjectException;
/**
* @Flow\Aspect
*/
class CompanyStartingPointAspect
{
/**
* @Flow\Inject
* @var NodeTypeManager
*/
protected $nodeTypeManager;
/**
* @param JoinPointInterface $joinPoint
* @throws CompanyInformationRetrievalException
* @throws QueryBuildingException
* @throws UnknownObjectException
* @Flow\Around("method(Neos\Neos\Controller\Service\NodesController->indexAction($searchTerm, $nodeIdentifiers, $workspaceName, $dimensions, $nodeTypes, $contextNode))")
*/
public function setAutomaticStartingPoint(JoinPointInterface $joinPoint)
{
$isCategoryNodeType = false;
foreach ($joinPoint->getMethodArgument('nodeTypes') as $nodeTypeName) {
$isCategoryNodeType = $this->nodeTypeManager->getNodeType($nodeTypeName)->isOfType('YourVendor.Base:Mixin.Category') || $isCategoryNodeType;
}
if($isCategoryNodeType === true) {
$contextNode = // YOUR CALCULATION HERE;
$joinPoint->setMethodArgument('contextNode', $contextNode);
}
$joinPoint->getAdviceChain()->proceed($joinPoint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment