Skip to content

Commit 65f6330

Browse files
author
Bernhard Schmitt
committed
Adjust to Neos 9 beta 11
1 parent 5e58d56 commit 65f6330

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

Classes/Fusion/AbstractComponentPresentationObjectFactory.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
namespace PackageFactory\AtomicFusion\PresentationObjects\Fusion;
1010

11+
use Neos\ContentRepository\Core\NodeType\NodeType;
1112
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
1213
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
1314
use Neos\Eel\ProtectedContextAwareInterface;
1415
use Neos\Flow\Annotations as Flow;
1516
use Neos\Flow\I18n\Translator;
17+
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
1618

1719
/**
1820
* The generic abstract component presentation object factory implementation
@@ -30,6 +32,20 @@ abstract class AbstractComponentPresentationObjectFactory implements
3032
#[Flow\Inject]
3133
protected Translator $translator;
3234

35+
#[Flow\Inject]
36+
protected NodeLabelGeneratorInterface $nodeLabelGenerator;
37+
38+
final protected function getNodeType(Node $node): ?NodeType
39+
{
40+
return $this->contentRepositoryRegistry->get($node->contentRepositoryId)
41+
->getNodeTypeManager()->getNodeType($node->nodeTypeName);
42+
}
43+
44+
final protected function getNodeLabel(Node $node): string
45+
{
46+
return $this->nodeLabelGenerator->getLabel($node);
47+
}
48+
3349
/**
3450
* @template T
3551
* @param class-string<T> $expectedType

Classes/Infrastructure/UriService.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@
1212
use GuzzleHttp\Psr7\Uri;
1313
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
1414
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
15+
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
1516
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
16-
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
1717
use Neos\Flow\Annotations as Flow;
1818
use Neos\Flow\Mvc\Controller\ControllerContext;
19-
use Neos\Flow\Mvc\Routing\UriBuilder;
2019
use Neos\Flow\ResourceManagement\PersistentResource;
2120
use Neos\Flow\ResourceManagement\ResourceManager;
2221
use Neos\Flow\Http;
2322
use Neos\Media\Domain\Model\AssetInterface;
2423
use Neos\Media\Domain\Repository\AssetRepository;
25-
use Neos\Neos\FrontendRouting\NodeAddressFactory;
26-
use Neos\Neos\FrontendRouting\NodeUriBuilder;
2724
use Neos\Flow\Mvc;
2825
use Neos\Flow\Core\Bootstrap;
26+
use Neos\Neos\FrontendRouting\NodeUriBuilderFactory;
2927
use PackageFactory\AtomicFusion\PresentationObjects\Fusion\UriServiceInterface;
3028
use Psr\Http\Message\UriInterface;
3129

@@ -38,29 +36,17 @@ final class UriService implements UriServiceInterface
3836
private ?ControllerContext $controllerContext = null;
3937

4038
public function __construct(
41-
private readonly ContentRepositoryRegistry $contentRepositoryRegistry,
4239
private readonly ResourceManager $resourceManager,
4340
private readonly AssetRepository $assetRepository,
44-
private readonly Bootstrap $bootstrap
41+
private readonly Bootstrap $bootstrap,
42+
private readonly NodeUriBuilderFactory $nodeUriBuilderFactory,
4543
) {
4644
}
4745

4846
public function getNodeUri(Node $documentNode, bool $absolute = false, ?string $format = null): UriInterface
4947
{
50-
$contentRepository = $this->contentRepositoryRegistry->get(
51-
$documentNode->subgraphIdentity->contentRepositoryId
52-
);
53-
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
54-
$nodeAddress = $nodeAddressFactory->createFromNode($documentNode);
55-
56-
$uriBuilder = new UriBuilder();
57-
$uriBuilder->setRequest($this->getControllerContext()->getRequest());
58-
$uriBuilder
59-
->setCreateAbsoluteUri($absolute)
60-
->setFormat($format ?: 'html');
61-
62-
return NodeUriBuilder::fromUriBuilder($uriBuilder)
63-
->uriFor($nodeAddress);
48+
return $this->nodeUriBuilderFactory->forActionRequest($this->getControllerContext()->getRequest())
49+
->uriFor(NodeAddress::fromNode($documentNode));
6450
}
6551

6652
public function getResourceUri(string $packageKey, string $resourcePath): UriInterface

0 commit comments

Comments
 (0)