froala / KMSFroalaEditorBundle

Symfony bundle for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
105 stars 33 forks source link

An exception has been thrown during the rendering of a template #51

Closed miojamo closed 5 years ago

miojamo commented 6 years ago

In Symfony4 editor is not working:

An exception has been thrown during the rendering of a template ("The "templating.helper.assets" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.").

{{ froala_display(form.content) }}

stefanneculai commented 6 years ago

@samarhxc I think we should replace the templating.helper.assets with assets.packages here:

https://github.com/froala/KMSFroalaEditorBundle/blob/5cbf5227a91caf0a6f9cad0d86c5dc9b6524076e/Twig/FroalaExtension.php#L54

What do you think?

sguionni commented 6 years ago

Maybe, but i'm not using Sf 4 for the moment. I have to install clean version of Sf 2, 3 and 4 to test all versions.

miojamo commented 6 years ago

Hi, any news about it? Thanks,

sguionni commented 6 years ago

I just tried on fresh Sf4 install and all is working. But you need to include the following bundles :

"symfony/asset": "^4.0", "symfony/twig-bundle": "^4.0",

In your bundles.php file you have to include Froala after those two bundles.

I continue testing because my profiler is broken.

lexeo commented 6 years ago

Hi. I've just installed Symfony 4.1 and ran into the same issue.
Found this solution.

Also I got exception: The "kms_froala_editor.media_manager" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead. while trying to upload image. It can be solved by adding public: true to services.yaml (the easiest way)

Parashuram-Sram commented 5 years ago

Hi, I have tried fresh installation of Symfony 4.2.3 and it looks working fine. Anyone still facing the issue?

stefanneculai commented 5 years ago

Looks like on S4.2.3 this is no longer happening.

SlimenTN commented 5 years ago

@lexeo can you be specific please ? where exactly should I put public: true ? this is my services.yaml file:

# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones
SlimenTN commented 5 years ago

so the solution is to call the service inside services.yaml file and make it public like so:

templating.helper.assets:
        class: Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper
        arguments: ['@assets.packages']
        public: true