PHP code example of agence-adeliom / easy-editor-bundle

1. Go to this page and download the library: Download agence-adeliom/easy-editor-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

agence-adeliom / easy-editor-bundle example snippets


class Article
{
    #[ORM\Column(name: 'content', type: \Doctrine\DBAL\Types\Types::JSON, nullable: true)]
    private $content = [];
}

class ArticleCrudController extends AbstractCrudController
{
    // Add the custom form theme
    public function configureCrud(Crud $crud): Crud
    {
        return $crud
            ->addFormTheme('@EasyEditor/form/editor_widget.html.twig')
            ;
    }

    public function configureFields(string $pageName): iterable
    {
        yield EasyEditorField::new('content');
    }
}

{% for block in object.content %}
    {{ easy_editor_block(block) }}
{% endfor %}

use Symfony\Contracts\EventDispatcher\Event;

$dispatcher->addListener('easy_editor.render_block', function (Event $event) {
    // will be executed when the easy_editor.render_block event is dispatched

    // Get
    $block = $event->getArgument('block');
    $settings = $event->getArgument('settings');

    // Set
    $event->setArgument("block", $block);
    $event->setArgument("settings", $settings);
});