1

I have a MessageCrudController and I made a custom action with easy admin to import some messages templates with an API

Now I want to be redirected to the list of my messages in my dashboard, but I don't know how to do that, It's my first custom action

there is page where I want to be redirected :

enter image description here

there is what I tried :

MessageCrudController

public function fetchMessages()
    {
      some logic to get my messages...
      return $this->redirect($this->generateUrl('admin', [
                'action' => 'index',
                'entity' => 'MessageCrudController',
            ]));
    }

Actually, I tried this return, and it redirect me to the homepage of my dashboard, and not to the messages page

someone have an Idea to how can I be redirected to my message page of my dashboard? thanks

7
  • What is that "message page"? How did you configure that in the first place? Commented Nov 7, 2022 at 10:16
  • Maybe symfonycasts.com/screencast/easyadminbundle/… could help? Commented Nov 7, 2022 at 10:17
  • Nico Haase, "message page" is the page of the list of my messages in the dashboard of easyadmin Commented Nov 7, 2022 at 10:19
  • Please add all clarification to your question by editing it Commented Nov 7, 2022 at 10:29
  • I edited with a screen of my message page Commented Nov 7, 2022 at 10:34

1 Answer 1

2

The 'entity' key seems to be wrong for url generator properties.

I prefer to get AdminUrlGenerator service from the container and generate urls using it:

$this->container->get(AdminUrlGenerator::class)
    ->setController(MessageCrudController::class)
    ->setAction(Action::INDEX)
    ->generateUrl();

This way much more easy to avoid mistakes here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.