Skip to content

Commit

Permalink
Merge pull request #12 from sitegeist/task/fixLinkGeneration
Browse files Browse the repository at this point in the history
TASK: Fix generation of links in occurences command
  • Loading branch information
mficzel committed Jan 5, 2024
2 parents 89ac419 + c919820 commit 4323b76
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 67 deletions.
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.

0 comments on commit 4323b76

Please sign in to comment.