Skip to content
Snippets Groups Projects
Commit 2daf4e46 authored by Eirik Morland's avatar Eirik Morland
Browse files

Make it possible to alter the rendered editor.

parent 805dd384
Branches
No related tags found
No related merge requests found
......@@ -3,10 +3,8 @@
namespace Drupal\image_canvas_editor_api\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Url;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\image_canvas_editor_api\Plugin\EditorPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
......@@ -28,13 +26,11 @@ class EditorController extends ControllerBase {
/**
* Constructs the controller object.
*
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
*/
public function __construct(EntityTypeManagerInterface $entity_manager, EditorPluginManager $manager) {
public function __construct(EntityTypeManagerInterface $entity_manager, EditorPluginManager $manager, ModuleHandlerInterface $module_handler) {
$this->entityTypeManager = $entity_manager;
$this->pluginManager = $manager;
$this->moduleHandler = $module_handler;
}
/**
......@@ -43,7 +39,8 @@ class EditorController extends ControllerBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.manager'),
$container->get('plugin.manager.image_editor_plugin')
$container->get('plugin.manager.image_editor_plugin'),
$container->get('module_handler')
);
}
......@@ -75,7 +72,9 @@ class EditorController extends ControllerBase {
/** @var \Drupal\file\Entity\File $file */
$image_url = file_create_url($file->getFileUri());
$build['editor'] = $instance->renderEditor($image_url);
$editor = $instance->renderEditor($image_url);
$this->moduleHandler->alter('image_canvas_editor_api_editor_render', $editor);
$build['editor'] = $editor;
$build['save'] = [
'#type' => 'inline_template',
'#template' => '<button class="btn button image-canvas-editor-save">{{ save }}</button>',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment