ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 5 replies, has 2 voices, and was last updated by Mike Kudelya Mike Kudelya 10 months, 2 weeks ago.

  • Creator
    Topic
  • #24148

    kroder
    Participant

    Good day.
    I’m trying to override couple of actions from OroEmailBundle/EmailController.
    No problems with common controllers through bundle inheritance, I redefined actions that I need and the rest of actions from EmailBundle/Controller/* are fine.
    The problem with controllers inside EmailBundle/Controller/Api/Rest/*, they all fall away no matter what I’m trying to write in routing.yml and routing_api.yml.
    Could anyone give me any advice or working example of these files to keep rest api controllers alive?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #24203
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    Try to use this approach:

    Add to src/Custom/Bundle/OroBundle/Resources/config/oro/routing.yml:

    Add to src/Custom/Bundle/OroBundle/Resources/config/oro/routing_api.yml:

    and finally api controller src/Custom/Bundle/OroBundle/Controller/Api/Rest/EmailController.php:

    #24208

    kroder
    Participant

    Hi Mike, thanks for answer, I got all api routes available now.
    But new question appeared: is it normal, that some actions (actually all in OroEmailBundle\Controller except EmailController itself, EmailTemplateController as example) don’t have specified names in their @Route annotations? Because there are references from other code (‘oro_email_emailtemplate_index’ as example) which use generated action names, as I understand. So when I override bundle – these actions change their default names and I got ‘route not found’ exceptions. Should I inherit these controllers by myself and specify correct names for routes or it could be fixed in platform code?

    #24219
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    Yes, by default @Route(name) is auto-generated. I think it is not normal, that route name is missed, it is historically happened.

    The best way to override business logic it is override service class name which this controller called, for example you can do this via Dependency Injection or event listener.

    But if you really want to override controller, you should do the following work. Unfortunately EmailTemplateController.php doesn’t contain any route name. You should copy it in your custom bundle and add route name to each action according to original auto-generated name (for example oro_email_emailtemplate_index). If you would have route names in controller, you will override only a few actions. Also you should create your routing.yml:

    #24223

    kroder
    Participant

    Thank you, Mike. Pretty clear now.
    Just in case: will it make any sense if I’ll create a pull request with route names in those two OroEmailBundle controllers?

    #24234
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    It will be great!

    Thank you in advance!

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.