Skip to content

Commit

Permalink
TASK: Prefer ActionRequest over ControllerContext in MenuProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 6, 2024
1 parent 88691b5 commit 26687fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function indexAction(string $node = null)
$this->nodeTypeGroupsAndRolesProvider->getNodeTypes(),
'menu' =>
$this->menuProvider->getMenu(
controllerContext: $this->controllerContext,
actionRequest: $this->request,
),
'initialState' =>
$this->initialStateProvider->getInitialState(
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/InitialData/MenuProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Neos\Neos\Ui\Domain\InitialData;

use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\ActionRequest;

/**
* Retrieves all data needed to render the main burger menu located in the
Expand All @@ -27,5 +27,5 @@ interface MenuProviderInterface
/**
* @return array<int,array{label:string,icon:string,uri:string,target:string,children:array<int,array{icon:string,label:string,uri:string,position?:string,isActive:bool,target:string,skipI18n:bool}>}>
*/
public function getMenu(ControllerContext $controllerContext): array;
public function getMenu(ActionRequest $actionRequest): array;
}
15 changes: 14 additions & 1 deletion Classes/Infrastructure/Neos/MenuProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
namespace Neos\Neos\Ui\Infrastructure\Neos;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\ActionResponse;
use Neos\Flow\Mvc\Controller\Arguments;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\Routing\UriBuilder;
use Neos\Neos\Controller\Backend\MenuHelper;
use Neos\Neos\Ui\Domain\InitialData\MenuProviderInterface;
use Neos\Utility\PositionalArraySorter;
Expand All @@ -29,8 +33,17 @@ final class MenuProvider implements MenuProviderInterface
#[Flow\Inject]
protected MenuHelper $menuHelper;

public function getMenu(ControllerContext $controllerContext): array
public function getMenu(ActionRequest $actionRequest): array
{
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($actionRequest);
$controllerContext = new ControllerContext(
$actionRequest,
new ActionResponse(),
new Arguments(),
$uriBuilder
);

$modulesForMenu = $this->menuHelper->buildModuleList($controllerContext);

$result = [];
Expand Down

0 comments on commit 26687fa

Please sign in to comment.