OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions EventListener on an extended bundle

This topic contains 5 replies, has 2 voices, and was last updated by  Mike Kudelya 7 years, 8 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #28975

    oro_newbie
    Participant

    Hi,

    I have extended the Account Bundle as per here and placed my custom views in the app/Resources/{BUNDLE_NAME}/views/ directory. This works fine and I can override the datagrid.yml file the same way.

    But I need to make few changes with the way the records of Accounts are displayed and this I believe can only be modified using an event listener. As such, where do I place the EventListener? I have seen Yehven’s advice here along with link to the code but it doesn’t explain for extended bundles I think.

    I tried placing the EventListener (which looks same like the CallListener in the above link) at app\Resources\OroCRMAccountBundle\EventListener\Datagrid\AccountListener.php but that doesn’t work. I even tried placing the same path in src/ instead of app/ but no luck either. Does this need to be registered in services.yml of the Account Bundle (well I tried that too).

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #28976

    Mike Kudelya
    Participant

    Hi,

    I have created new bundle OroBundle. Here i explained how to do it. Further i created src/Custom/Bundle/OroBundle/EventListener/AccountListener.php

    and registered it in src/Custom/Bundle/OroBundle/Resources/config/services.yml:

    Do not forget add services.yml to dependency injection extension, in my case it is here src/Custom/Bundle/OroBundle/DependencyInjection/CustomOroExtension.php ([namespace][bundle name]Extension.php)

    #28977

    oro_newbie
    Participant

    Hi Mike,

    Thanks for the above. It works quite well.

    In my case, I was trying to override the datagrid so my services.yml went like this:

    I understand that the “accounts-grid” above should be the name of the grid (which can be found in datagrid.yml or in the markup of the grid that you need to modify). Regarding the event parameter:

    do you know how this is getting derived?

    Thanks.

    #28978

    Mike Kudelya
    Participant

    Hi,

    Can you explain more detail about “do you know how this is getting derived?” ? “oro_datagrid.datagrid.build.before.accounts-grid” is dynamic event name, just write right grid name there and fill method section.

    #28979

    oro_newbie
    Participant

    Hi Mike,

    What I actually meant was, is it something like [bundle_name].object.event etc.? Do you know where I can find the list of such events that can be used with datagrid? That would be very helpful.

    Thanks.

    #28980

    Mike Kudelya
    Participant

    Hi,

    You can find them there: Oro\Bundle\DataGridBundle\Event

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

The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.

Back to top