Verified Commit de3c0152 authored by apaderno's avatar apaderno Committed by apaderno
Browse files

Issue #3257953 by apaderno: When verifying the...

Issue #3257953 by apaderno: When verifying the libraries/ckeditor/plugins/dialogadvtab/plugin.js file exists, use the Drupal root directory path
parent ad1baa2b
......@@ -14,7 +14,7 @@ function ckeditor_advanced_tab_requirements($phase) {
$requirements = [];
if ($phase == 'install' || $phase == 'runtime') {
$path = DRUPAL_ROOT . '/libraries/ckeditor/plugins/dialogadvtab/';
$path = \Drupal::root() . '/libraries/ckeditor/plugins/dialogadvtab/';
$t_args = [':plugin_url' => 'https://ckeditor.com/cke4/addon/dialogadvtab', ':directory' => $path];
if (file_exists($path . 'plugin.js')) {
......
......@@ -22,6 +22,13 @@
*/
class CKEditorAdvancedTab extends CKEditorPluginBase implements ContainerFactoryPluginInterface {
/**
* Drupal root directory.
*
* @var string
*/
protected $root;
/**
* The logger service.
*
......@@ -38,6 +45,8 @@ class CKEditorAdvancedTab extends CKEditorPluginBase implements ContainerFactory
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
* @param string $root
* Drupal root directory.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
......@@ -45,8 +54,9 @@ class CKEditorAdvancedTab extends CKEditorPluginBase implements ContainerFactory
* @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
* The module extension list.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, LoggerInterface $logger, TranslationInterface $translation_manager, ModuleExtensionList $extension_list_module) {
public function __construct(array $configuration, $plugin_id, array $plugin_definition, string $root, LoggerInterface $logger, TranslationInterface $translation_manager, ModuleExtensionList $extension_list_module) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->root = $root;
$this->logger = $logger;
$this->setStringTranslation($translation_manager);
$this->moduleList = $extension_list_module;
......@@ -58,6 +68,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration, $plugin_id, $plugin_definition,
$container->getParameter('app.root'),
$container->get('logger.channel.ckeditor_advanced_tab'),
$container->get('string_translation'),
$container->get('extension.list.module')
......@@ -69,7 +80,7 @@ public static function create(ContainerInterface $container, array $configuratio
*/
public function getFile() {
$file = 'libraries/ckeditor/plugins/dialogadvtab/plugin.js';
if (!file_exists($file)) {
if (!file_exists($this->root . '/' . $file)) {
$this->logger->error(
'The %file file cannot be found. Please follow the installation instructions given in the README.md file.',
['%file' => $file]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment