Forums › Forums › OroCRM › OroCRM – How do I? Questions › Override contact or any api
This topic contains 8 replies, has 2 voices, and was last updated by pauloasterio 8 years, 1 month ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- February 11, 2016 at 6:24 am #28749
I have overriden the contact Bundle so the /contact is now getting my custom templates, my question is how do I override the /api/rest route so it can reach the api/rest controllers on my custom bundle ?
- CreatorTopic
- AuthorReplies
- February 11, 2016 at 6:59 am #28750
Hello, pauloasterio.
You can use the same approach – override routing and controllers in your custom bundle. See http://oroinc.com/orocrm/doc/current/cookbook/how-to-extend-existing-bundle and http://symfony.com/doc/2.7/cookbook/bundles/inheritance.html#overriding-controllers
February 11, 2016 at 7:29 am #28751thanks for your response !
maybe I am getting a syntax confusion, I am still not getting the route to my local api controller! can you help me ?
this is my @CustomBundle/config/oro/routing.yml
YAML1234567891011121314mybundle_contact_bundle:resource: "@!OroCRMContactBundle/Controller"type: annotationprefix: /contactmybundle_contact_bundle_api:resource: "@!OroCRMContactBundle/Resources/config/oro/routing_api.yml"type: restprefix: api/rest/{version}requirements:version: latest|v1defaults:version: latestthis is my @CustomBundle/config/oro/routing_api.yml
YAML1234567891011121314151617myapi_contact_api:resource: "@!OroCRMContactBundle/Controller/Api/Rest/ContactController.php"type: restmyapi_contact_group_api:resource: "@!OroCRMContactBundle/Controller/Api/Rest/ContactGroupController.php"type: restmyapi_contact_address_api:resource: "@!OroCRMContactBundle/Controller/Api/Rest/ContactAddressController.php"type: restparent: myapi_contact_apimyapi_contact_phone_api:resource: "@!OroCRMContactBundle/Controller/Api/Rest/ContactPhoneController.php"type: restparent: myapi_contact_apiFebruary 11, 2016 at 7:37 am #28752Using these configuration files you said Symfony to use controllers from ContactBundle, because “@!OroCRMContactBundle” means that Symfony will not use bundle inheritance to resolve path.
If you need to override controller you can simply remove these two files and create your controller with the same name and in the same directory as the original one.
February 12, 2016 at 7:39 am #28753thank you worked! I was able to override the API.
I am just with another problem, I am trying to override contacts main datagrid, when I copy the datagrid.yml to my bundle, I get an empty contact grid! All I did in this new bundle was to copy the api controller and now I am trying to customize the grid columns. can you help ?
February 12, 2016 at 8:04 am #28754There are two ways to do that:
1) by overriding of whole template – you have to create grid in your bundle (you can extend existing one or create new from scratch), then override template of index page (index.html.twig) and render your grid instead of the default one;
2) by customizing of original grid – you have to create listener to the one of datagrid events, e.g. build.pre, and alter configuration there (example https://github.com/orocrm/crm/blob/d11222bb360362b778d62b0e25a0dd6e252304ab/src/OroCRM/Bundle/MagentoBundle/Resources/config/services.yml#L488)
February 12, 2016 at 10:03 am #28755Hi Yevhen,
My setup is the like this
https://www.dropbox.com/s/5cpi07j96p168yz/printScreen.png?dl=0
And I still getting a blank contact grid, what am I missing?
Appreciate your help.
tks
February 15, 2016 at 2:01 am #28756Directory structure looks fine, so your issue related either to template, or to grid itself. Please, check the template used to render index page, if nothing there – check grid itself. Also it might be useful to look at application, PHP and web-server logs – there might be some clues.
February 15, 2016 at 4:31 am #28757Hello,
I got it fixed just by changing the grid name on the datagrid.yml and the twig template that renders it.
thank you for your response.
- AuthorReplies
The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.