Skip to content

Commit

Permalink
TASK: NodeTypeWithFallbackProvider don't reimport `contentRepositor…
Browse files Browse the repository at this point in the history
…yRegistry` but declare that property must exist

phpstan will catch invalid use of this trait
  • Loading branch information
mhsdesign committed Sep 24, 2023
1 parent bae8a3d commit 7f2dc54
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;

/**
* Utility trait for retrieving node types for nodes with a built-in fallback mechanism
*
* @property ContentRepositoryRegistry $contentRepositoryRegistry
*/
trait NodeTypeWithFallbackProvider
{
#[Flow\Inject]
protected ContentRepositoryRegistry $_contentRepositoryRegistry;

protected function getNodeType(Node $node): NodeType
{
$nodeTypeManager = $this->_contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager();
$nodeTypeManager = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager();

return $nodeTypeManager->hasNodeType($node->nodeTypeName)
? $nodeTypeManager->getNodeType($node->nodeTypeName)
Expand Down

0 comments on commit 7f2dc54

Please sign in to comment.