Search code examples
phpsymfonydatagridorocrm

Symfony / Orocrm : yml file is not set?


Website : Open source frameword based on Symfony 2.7 My entitie : Entity/Download.php (with properties "id", "creation_date" and "name")

I'm working on my own Bundle and I try to create a new datagrid based on my own entitie, I follow this tutorial. Below is what I've done :

  • Create /resources/config/datagrid.yml, with a very light datagrid.
  • Edit DependencyInjection/MyBundleExtension.php to load datagrid.yml.
  • Edit my twig view to render the datagrid :

{% import 'PimDataGridBundle::macros.html.twig' as dataGrid %}

{% block content %} {{ dataGrid.renderGrid('custom_download', { localeCode: locale_code() }) }}

{% endblock %}

But this error is generated :

Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("A configuration for "custom_download" datagrid was not found.

-> If I try the same code with another gridname already existing that works then I believe the problem comes from my new datagrid but I don't understand what's wrong : does the kernel include my YML config file ? I don't think so.

Thanks for your help.


Solution

  • You create datagrid.yml in /resources/config folder. But according OroPlatform conventions configuration file should be placed in Resources/config/oro folder of your bundle and named datagrids.yml. Exactly in this path OroPlatform is looking for datagrid configuration. https://github.com/oroinc/platform/blob/2.5/src/Oro/Bundle/DataGridBundle/Provider/ConfigurationProvider.php#L154-L160

    Please move your configuration into correct directory and filename. And It will be work. And of course you should remove this file loading from DependencyInjection/MyBundleExtension.php OroPlatform do it automatically.

    For more detailed understanding how you can use OroPlatform datagrid features please read bundle documentation https://github.com/oroinc/platform/blob/2.5/src/Oro/Bundle/DataGridBundle/Resources/doc/backend/datagrid.md