Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Fix generation of links in occurences command #12

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Classes/Command/ReportCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ public function occurencesCommand($nodeType, $workspaces = 'live', $limit = 5, $
$this->outputLine();
$this->outputDimensionPreset($dimensionPreset);
$this->outputLine();
// $this->outputLine('<b>Link:</b> %s', [
// $closestDocumentNode ? $this->nodeUriService->buildUriFromNode(
// $closestDocumentNode
// ) : 'No Document found'
// ]);
$this->outputLine('<b>Link:</b> %s', [
$closestDocumentNode ? $this->nodeUriService->buildUriFromNode(
$closestDocumentNode
) : 'No Document found'
]);
$this->outputLine();
}
}
Expand Down Expand Up @@ -424,7 +424,7 @@ public function urisCommand($nodeType = 'Neos.Neos:Document', $filter = '', $wor
*/
protected function getClosestDocumentNode(NodeInterface $node)
{
if ($node->getNodeType()->isOfType('TYPO.Neos:Document')) {
if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
return $node;
}

Expand Down
42 changes: 20 additions & 22 deletions Classes/ContentRepository/Service/NodeUriService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Configuration\ConfigurationManager;
use Neos\Flow\Mvc\Routing\Dto\ResolveContext;
use Neos\Flow\Mvc\Routing\Dto\RouteParameters;
use Neos\Flow\Mvc\Routing\RouterInterface;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\Domain\Service\NodeShortcutResolver;
Expand Down Expand Up @@ -49,12 +51,6 @@ class NodeUriService
*/
protected $router;

/**
* @Flow\Inject
* @var UriBuilder
*/
protected $uriBuilder;

/**
* Constructor
*/
Expand Down Expand Up @@ -101,22 +97,24 @@ public function buildUriFromNode(NodeInterface $node, $resolveShortcuts = TRUE)
1414771137);
}

$reflection = new \ReflectionClass($this->uriBuilder);
$property = $reflection->getProperty('baseUriProvider');
$property->setAccessible(true);
$subj = $property->getValue($this->uriBuilder);

//
// create a dummy parent request
//
$httpRequest = new ServerRequest('get', 'https://domain.tld' );
$request = ActionRequest::fromHttpRequest($httpRequest);
$this->uriBuilder->setRequest($request);

$uri = $this->uriBuilder
->setFormat('html')
->uriFor('show', array('node' => $resolvedNode), 'Frontend\Node', 'Neos.Neos');
$routeValues = [
'node' => $resolvedNode,
'@package' => 'neos.neos',
'@controller' => 'frontend\node',
'@action' => 'show',
'@format' => 'html',
];

$uri = new Uri('http://localhost');
$resolveContext = new ResolveContext(
$uri,
$routeValues,
false ,
'',
RouteParameters::createEmpty()->withParameter('requestUriHost', $uri->getHost())
);

return $uri;
$uri = $this->router->resolve($resolveContext);
return (string) $uri;
}
}
25 changes: 0 additions & 25 deletions Classes/Service/BaseUriProvider.php

This file was deleted.

14 changes: 0 additions & 14 deletions Classes/Service/UriBuilder.php

This file was deleted.