coopTilleuls / CoopTilleulsCKEditorSonataMediaBundle

Integrates SonataMediaBundle for Symfony with CKEditor
http://les-tilleuls.coop
MIT License
53 stars 41 forks source link

Missing check if provider key in persistent_parameters array is set in MediaAdmin:browser.html.twig #17

Closed lordrhodos closed 8 years ago

lordrhodos commented 9 years ago

I've integrated the latest versions of the following bundles:

    "sonata-project/media-bundle": "dev-master",
    "egeloen/ckeditor-bundle": "dev-master",
    "tilleuls/ckeditor-sonata-media-bundle": "dev-master

and I get the following error when trying to browse the media files within the CKEditor:

Key "provider" for array with keys "context, category, hide_context" does not exist in CoopTilleulsCKEditorSonataMediaBundle:MediaAdmin:browser.html.twig at line 47

This seems to be related to a change of the MediaBundle introduced with this commit where the provider entry got removed from the parameters array.

lordrhodos commented 9 years ago

For me it worked to check if the provider key is available, but that is rather a dirty hack than a solution for the change introduced in the MediaBundle.

Resources/views/MediaAdmin/browser.html.twig - Line 47 to 59:

{% if (persistent_parameters.provider is defined) and (not persistent_parameters.provider) %}
    <li class="active"><a href="{{ admin.generateUrl('browser', {'context': persistent_parameters.context, 'provider': null}|merge(ckParameters)) }}">{{ "link.all_providers"|trans({}, 'SonataMediaBundle') }}</a></li>
{% else %}
    <li><a href="{{ admin.generateUrl('browser', {'context': persistent_parameters.context, 'provider': null}|merge(ckParameters)) }}">{{ "link.all_providers"|trans({}, 'SonataMediaBundle') }}</a></li>
{% endif %}

 {% for provider_name in providers %}
     {% if (persistent_parameters.provider is defined) and (persistent_parameters.provider == provider_name) %}
        <li class="active"><a href="{{ admin.generateUrl('browser', {'context': persistent_parameters.context, 'provider': provider_name}|merge(ckParameters)) }}">{{ provider_name|trans({}, 'SonataMediaBundle') }}</a></li>
    {% else %}
        <li><a href="{{ admin.generateUrl('browser', {'context': persistent_parameters.context, 'provider': provider_name}|merge(ckParameters)) }}">{{ provider_name|trans({}, 'SonataMediaBundle') }}</a></li>
    {% endif %}
{% endfor %}