Skip to content

Commit 98ffdc8

Browse files
committed
TASK: Update references editor to also use Flow\Route and AbstractQueryController like the new LinkEditor
adjustments for 28cb6ef
1 parent 0811e5c commit 98ffdc8

File tree

8 files changed

+70
-65
lines changed

8 files changed

+70
-65
lines changed

Classes/ReferencesEditor/Application/GetChildrenForTreeNode/Controller/GetChildrenForTreeNodeController.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,37 @@
1515
namespace Neos\Neos\Ui\ReferencesEditor\Application\GetChildrenForTreeNode\Controller;
1616

1717
use Neos\Flow\Annotations as Flow;
18+
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
19+
use Neos\Neos\Ui\Infrastructure\MVC\AbstractQueryController;
20+
use Neos\Neos\Ui\Infrastructure\MVC\QueryResponseHelper;
1821
use Neos\Neos\Ui\ReferencesEditor\Application\GetChildrenForTreeNode\GetChildrenForTreeNodeQuery;
1922
use Neos\Neos\Ui\ReferencesEditor\Application\GetChildrenForTreeNode\GetChildrenForTreeNodeQueryHandler;
2023
use Neos\Neos\Ui\LinkEditor\Application\Shared\NodeWasNotFound;
21-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryController;
22-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryResponse;
24+
use Psr\Http\Message\ResponseInterface;
2325

2426
#[Flow\Scope("singleton")]
25-
final class GetChildrenForTreeNodeController extends QueryController
27+
final class GetChildrenForTreeNodeController extends AbstractQueryController
2628
{
2729
#[Flow\Inject]
2830
protected GetChildrenForTreeNodeQueryHandler $queryHandler;
2931

30-
public function processQuery(array $arguments): QueryResponse
32+
#[Flow\Route('neos/references-editor/get-children-for-tree-node')]
33+
public function processQueryAction(): ResponseInterface
3134
{
35+
$arguments = $this->request->getArguments();
36+
if (!isset($arguments['contentRepositoryId'])) {
37+
/** @todo send from UI */
38+
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
39+
$arguments['contentRepositoryId'] = $siteDetectionResult->contentRepositoryId->value;
40+
}
41+
3242
try {
3343
$query = GetChildrenForTreeNodeQuery::fromArray($arguments);
3444
$queryResult = $this->queryHandler->handle($query);
3545

36-
return QueryResponse::createSuccess($queryResult);
46+
return QueryResponseHelper::createSuccess($queryResult);
3747
} catch (NodeWasNotFound $e) {
38-
return QueryResponse::createServerSideErrorForBadRequest($e);
48+
return QueryResponseHelper::createServerSideErrorForBadRequest($e);
3949
}
4050
}
4151
}

Classes/ReferencesEditor/Application/GetNodeSummary/Controller/GetNodeSummaryController.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,37 @@
1515
namespace Neos\Neos\Ui\ReferencesEditor\Application\GetNodeSummary\Controller;
1616

1717
use Neos\Flow\Annotations as Flow;
18+
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
19+
use Neos\Neos\Ui\Infrastructure\MVC\AbstractQueryController;
20+
use Neos\Neos\Ui\Infrastructure\MVC\QueryResponseHelper;
1821
use Neos\Neos\Ui\LinkEditor\Application\GetNodeSummary\GetNodeSummaryQuery;
1922
use Neos\Neos\Ui\LinkEditor\Application\GetNodeSummary\GetNodeSummaryQueryHandler;
2023
use Neos\Neos\Ui\LinkEditor\Application\Shared\NodeWasNotFound;
21-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryController;
22-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryResponse;
24+
use Psr\Http\Message\ResponseInterface;
2325

2426
#[Flow\Scope("singleton")]
25-
final class GetNodeSummaryController extends QueryController
27+
final class GetNodeSummaryController extends AbstractQueryController
2628
{
2729
#[Flow\Inject]
2830
protected GetNodeSummaryQueryHandler $queryHandler;
2931

30-
public function processQuery(array $arguments): QueryResponse
32+
#[Flow\Route('neos/references-editor/get-node-summary')]
33+
public function processQueryAction(): ResponseInterface
3134
{
35+
$arguments = $this->request->getArguments();
36+
if (!isset($arguments['contentRepositoryId'])) {
37+
/** @todo send from UI */
38+
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
39+
$arguments['contentRepositoryId'] = $siteDetectionResult->contentRepositoryId->value;
40+
}
41+
3242
try {
3343
$query = GetNodeSummaryQuery::fromArray($arguments);
3444
$queryResult = $this->queryHandler->handle($query);
3545

36-
return QueryResponse::createSuccess($queryResult);
46+
return QueryResponseHelper::createSuccess($queryResult);
3747
} catch (NodeWasNotFound $e) {
38-
return QueryResponse::createServerSideErrorForBadRequest($e);
48+
return QueryResponseHelper::createServerSideErrorForBadRequest($e);
3949
}
4050
}
4151
}

Classes/ReferencesEditor/Application/GetReferencesSummary/Controller/GetReferencesSummaryController.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,37 @@
1515
namespace Neos\Neos\Ui\ReferencesEditor\Application\GetReferencesSummary\Controller;
1616

1717
use Neos\Flow\Annotations as Flow;
18+
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
19+
use Neos\Neos\Ui\Infrastructure\MVC\AbstractQueryController;
20+
use Neos\Neos\Ui\Infrastructure\MVC\QueryResponseHelper;
1821
use Neos\Neos\Ui\ReferencesEditor\Application\GetReferencesSummary\GetReferencesSummaryQuery;
1922
use Neos\Neos\Ui\ReferencesEditor\Application\GetReferencesSummary\GetReferencesSummaryQueryHandler;
20-
// todo unhack me
2123
use Neos\Neos\Ui\LinkEditor\Application\Shared\NodeWasNotFound;
22-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryController;
23-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryResponse;
24+
use Psr\Http\Message\ResponseInterface;
2425

2526
#[Flow\Scope("singleton")]
26-
final class GetReferencesSummaryController extends QueryController
27+
final class GetReferencesSummaryController extends AbstractQueryController
2728
{
2829
#[Flow\Inject]
2930
protected GetReferencesSummaryQueryHandler $queryHandler;
3031

31-
public function processQuery(array $arguments): QueryResponse
32+
#[Flow\Route('neos/references-editor/get-references-summary')]
33+
public function processQueryAction(): ResponseInterface
3234
{
35+
$arguments = $this->request->getArguments();
36+
if (!isset($arguments['contentRepositoryId'])) {
37+
/** @todo send from UI */
38+
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
39+
$arguments['contentRepositoryId'] = $siteDetectionResult->contentRepositoryId->value;
40+
}
41+
3342
try {
3443
$query = GetReferencesSummaryQuery::fromArray($arguments);
3544
$queryResult = $this->queryHandler->handle($query);
3645

37-
return QueryResponse::createSuccess($queryResult);
46+
return QueryResponseHelper::createSuccess($queryResult);
3847
} catch (NodeWasNotFound $e) {
39-
return QueryResponse::createServerSideErrorForBadRequest($e);
48+
return QueryResponseHelper::createServerSideErrorForBadRequest($e);
4049
}
4150
}
4251
}

Classes/ReferencesEditor/Application/GetTree/Controller/GetTreeController.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,38 @@
1515
namespace Neos\Neos\Ui\ReferencesEditor\Application\GetTree\Controller;
1616

1717
use Neos\Flow\Annotations as Flow;
18+
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
19+
use Neos\Neos\Ui\Infrastructure\MVC\AbstractQueryController;
20+
use Neos\Neos\Ui\Infrastructure\MVC\QueryResponseHelper;
21+
use Neos\Neos\Ui\LinkEditor\Application\Shared\NodeWasNotFound;
1822
use Neos\Neos\Ui\ReferencesEditor\Application\GetTree\GetTreeQuery;
1923
use Neos\Neos\Ui\ReferencesEditor\Application\GetTree\GetTreeQueryHandler;
2024
use Neos\Neos\Ui\ReferencesEditor\Application\GetTree\StartingPointWasNotFound;
21-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryController;
22-
use Neos\Neos\Ui\LinkEditor\Framework\MVC\QueryResponse;
25+
use Psr\Http\Message\ResponseInterface;
2326

2427
#[Flow\Scope("singleton")]
25-
final class GetTreeController extends QueryController
28+
final class GetTreeController extends AbstractQueryController
2629
{
2730
#[Flow\Inject]
2831
protected GetTreeQueryHandler $queryHandler;
2932

30-
public function processQuery(array $arguments): QueryResponse
33+
#[Flow\Route('neos/references-editor/get-tree')]
34+
public function processQueryAction(): ResponseInterface
3135
{
36+
$arguments = $this->request->getArguments();
37+
if (!isset($arguments['contentRepositoryId'])) {
38+
/** @todo send from UI */
39+
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
40+
$arguments['contentRepositoryId'] = $siteDetectionResult->contentRepositoryId->value;
41+
}
42+
3243
try {
3344
$query = GetTreeQuery::fromArray($arguments);
3445
$queryResult = $this->queryHandler->handle($query);
3546

36-
return QueryResponse::createSuccess($queryResult);
37-
} catch (StartingPointWasNotFound $e) {
38-
return QueryResponse::createServerSideErrorForBadRequest($e);
47+
return QueryResponseHelper::createSuccess($queryResult);
48+
} catch (StartingPointWasNotFound|NodeWasNotFound $e) {
49+
return QueryResponseHelper::createServerSideErrorForBadRequest($e);
3950
}
4051
}
4152
}

Configuration/Policy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ privilegeTargets:
1616
matcher: 'method(Neos\Neos\Ui\LinkEditor\Application\.*\Controller\.*Controller->.*())'
1717

1818
'Neos.Neos.Ui:ReferencesEditor.ApiAccess':
19-
matcher: 'method(Neos\Neos\Ui\ReferencesEditor\Application\.*\Controller\.*Controller->processRequest())'
19+
matcher: 'method(Neos\Neos\Ui\ReferencesEditor\Application\.*\Controller\.*Controller->.*())'
2020

2121
'Neos\Neos\Security\Authorization\Privilege\ModulePrivilege':
2222

Configuration/Routes.yaml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,3 @@
2727
'ServiceSubRoutes':
2828
package: 'Neos.Neos.Ui'
2929
suffix: 'Service'
30-
31-
-
32-
name: 'GetReferencesSummary Query'
33-
uriPattern: 'neos/references-editor/get-references-summary'
34-
defaults:
35-
'@package': 'Neos.Neos.Ui'
36-
'@subpackage': 'ReferencesEditor\Application\GetReferencesSummary'
37-
'@controller': 'GetReferencesSummary'
38-
'@action': 'ignored'
39-
40-
-
41-
name: 'GetChildrenForTreeNode Query'
42-
uriPattern: 'neos/references-editor/get-children-for-tree-node'
43-
defaults:
44-
'@package': 'Neos.Neos.Ui'
45-
'@subpackage': 'ReferencesEditor\Application\GetChildrenForTreeNode'
46-
'@controller': 'GetChildrenForTreeNode'
47-
'@action': 'ignored'
48-
49-
-
50-
name: 'GetTree Query'
51-
uriPattern: 'neos/references-editor/get-tree'
52-
defaults:
53-
'@package': 'Neos.Neos.Ui'
54-
'@subpackage': 'ReferencesEditor\Application\GetTree'
55-
'@controller': 'GetTree'
56-
'@action': 'ignored'
57-
58-
-
59-
name: 'GetNodeSummary Query'
60-
uriPattern: 'neos/references-editor/get-node-summary'
61-
defaults:
62-
'@package': 'Neos.Neos.Ui'
63-
'@subpackage': 'ReferencesEditor\Application\GetNodeSummary'
64-
'@controller': 'GetNodeSummary'
65-
'@action': 'ignored'

Configuration/Settings.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ Neos:
252252
providerOptions:
253253
classNames:
254254
- Neos\Neos\Ui\LinkEditor\Application\*\Controller\*Controller
255+
- Neos\Neos\Ui\ReferencesEditor\Application\*\Controller\*Controller
255256

256257
Fusion:
257258
defaultContext:

packages/neos-ui-references-editor-custom-node-tree/src/application/SelectNodeTypeFilter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {SelectBox} from '@neos-project/react-ui-components';
1414

1515
import {getNodeTypeFilterOptions} from '../infrastructure/http';
1616
import {translate} from '@neos-project/neos-ui-i18n';
17-
import {globalRegistry} from '@neos-project/neos-ui/globalRegistry';
17+
import {getRegistryById} from '@neos-project/neos-ui-registry';
1818

1919
const searchNodeTypeFilterOptions = (
2020
searchTerm: string,
@@ -46,7 +46,7 @@ export const SelectNodeTypeFilter: React.FC<Props> = (props) => {
4646
return result.success.options.map((option) => ({
4747
value: option.value,
4848
icon: option.label.icon,
49-
label: globalRegistry.get('i18n').translate(option.label.label)
49+
label: getRegistryById('i18n').translate(option.label.label)
5050
}));
5151
}
5252

0 commit comments

Comments
 (0)