Skip to content

Commit

Permalink
Adjust to Neos 9 beta 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Schmitt committed Aug 15, 2024
1 parent 5e58d56 commit 65f6330
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
16 changes: 16 additions & 0 deletions Classes/Fusion/AbstractComponentPresentationObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

namespace PackageFactory\AtomicFusion\PresentationObjects\Fusion;

use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Eel\ProtectedContextAwareInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\I18n\Translator;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;

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

#[Flow\Inject]
protected NodeLabelGeneratorInterface $nodeLabelGenerator;

final protected function getNodeType(Node $node): ?NodeType
{
return $this->contentRepositoryRegistry->get($node->contentRepositoryId)
->getNodeTypeManager()->getNodeType($node->nodeTypeName);
}

final protected function getNodeLabel(Node $node): string
{
return $this->nodeLabelGenerator->getLabel($node);
}

/**
* @template T
* @param class-string<T> $expectedType
Expand Down
26 changes: 6 additions & 20 deletions Classes/Infrastructure/UriService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
use GuzzleHttp\Psr7\Uri;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\Routing\UriBuilder;
use Neos\Flow\ResourceManagement\PersistentResource;
use Neos\Flow\ResourceManagement\ResourceManager;
use Neos\Flow\Http;
use Neos\Media\Domain\Model\AssetInterface;
use Neos\Media\Domain\Repository\AssetRepository;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeUriBuilder;
use Neos\Flow\Mvc;
use Neos\Flow\Core\Bootstrap;
use Neos\Neos\FrontendRouting\NodeUriBuilderFactory;
use PackageFactory\AtomicFusion\PresentationObjects\Fusion\UriServiceInterface;
use Psr\Http\Message\UriInterface;

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

public function __construct(
private readonly ContentRepositoryRegistry $contentRepositoryRegistry,
private readonly ResourceManager $resourceManager,
private readonly AssetRepository $assetRepository,
private readonly Bootstrap $bootstrap
private readonly Bootstrap $bootstrap,
private readonly NodeUriBuilderFactory $nodeUriBuilderFactory,
) {
}

public function getNodeUri(Node $documentNode, bool $absolute = false, ?string $format = null): UriInterface
{
$contentRepository = $this->contentRepositoryRegistry->get(
$documentNode->subgraphIdentity->contentRepositoryId
);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$nodeAddress = $nodeAddressFactory->createFromNode($documentNode);

$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->getControllerContext()->getRequest());
$uriBuilder
->setCreateAbsoluteUri($absolute)
->setFormat($format ?: 'html');

return NodeUriBuilder::fromUriBuilder($uriBuilder)
->uriFor($nodeAddress);
return $this->nodeUriBuilderFactory->forActionRequest($this->getControllerContext()->getRequest())
->uriFor(NodeAddress::fromNode($documentNode));
}

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

0 comments on commit 65f6330

Please sign in to comment.