diff --git a/composer.json b/composer.json index 7b74a17d6..567925e27 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,8 @@ "phpunit/phpunit": "^10.0", "rector/rector": "^0.18.2", "sylius-labs/coding-standard": "^4.4", - "sylius/grid-bundle": "^1.13", + "sylius/grid": "*@dev", + "sylius/grid-bundle": "*@dev", "symfony/console": "^6.4 || ^7.1", "symfony/css-selector": "^6.4 || ^7.1", "symfony/dependency-injection": "^6.4 || ^7.1", diff --git a/src/Bundle/Grid/Renderer/TwigGridRenderer.php b/src/Bundle/Grid/Renderer/TwigGridRenderer.php index 7d541873c..cd86772a2 100644 --- a/src/Bundle/Grid/Renderer/TwigGridRenderer.php +++ b/src/Bundle/Grid/Renderer/TwigGridRenderer.php @@ -67,7 +67,10 @@ public function renderAction(GridViewInterface $gridView, Action $action, $data } $type = $action->getType(); - if (!isset($this->actionTemplates[$type])) { + $template = method_exists($action, 'getTemplate') ? $action->getTemplate() : null; + $template ??= $this->actionTemplates[$type] ?? null; + + if (null === $template) { throw new \InvalidArgumentException(sprintf('Missing template for action type "%s".', $type)); } @@ -77,7 +80,7 @@ public function renderAction(GridViewInterface $gridView, Action $action, $data $data, ); - return $this->twig->render($this->actionTemplates[$type], [ + return $this->twig->render($template, [ 'grid' => $gridView, 'action' => $action, 'data' => $data, diff --git a/src/Bundle/spec/Grid/Renderer/TwigGridRendererSpec.php b/src/Bundle/spec/Grid/Renderer/TwigGridRendererSpec.php index 309a7c21a..3d27a2c09 100644 --- a/src/Bundle/spec/Grid/Renderer/TwigGridRendererSpec.php +++ b/src/Bundle/spec/Grid/Renderer/TwigGridRendererSpec.php @@ -81,6 +81,7 @@ function it_throws_an_exception_if_template_is_not_configured_for_given_action_t ResourceGridView $gridView, Action $action, ): void { + $action->getOptions()->willReturn([]); $action->getType()->willReturn('foo'); $this diff --git a/tests/Application/src/Subscription/Grid/SubscriptionGrid.php b/tests/Application/src/Subscription/Grid/SubscriptionGrid.php index bfe7f6cf7..caa5b5c3b 100644 --- a/tests/Application/src/Subscription/Grid/SubscriptionGrid.php +++ b/tests/Application/src/Subscription/Grid/SubscriptionGrid.php @@ -51,7 +51,8 @@ public function buildGrid(GridBuilderInterface $gridBuilder): void ) ->addActionGroup( ItemActionGroup::create( - ShowAction::create(), + ShowAction::create() + ->setTemplate('subscription/grid/action/show.html.twig'), UpdateAction::create(), DeleteAction::create(), Action::create('accept', 'apply_transition') diff --git a/tests/Application/src/Tests/Controller/SubscriptionUiTest.php b/tests/Application/src/Tests/Controller/SubscriptionUiTest.php index a7f9d725d..c467c6a8a 100644 --- a/tests/Application/src/Tests/Controller/SubscriptionUiTest.php +++ b/tests/Application/src/Tests/Controller/SubscriptionUiTest.php @@ -65,12 +65,12 @@ public function it_allows_browsing_subscriptions(): void } $this->assertStringContainsString('