Verified Commit 95503bfe authored by apaderno's avatar apaderno Committed by apaderno
Browse files

Issue #3257715 by apaderno: Log an error when the plugin.js file isn't found

parent d6953e93
services:
logger.channel.ckeditor_advanced_tab:
parent: logger.channel_base
arguments: ['ckeditor_advanced_tab']
......@@ -3,7 +3,10 @@
namespace Drupal\ckeditor_advanced_tab\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\editor\Entity\Editor;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines the "Advanced Tab" plugin.
......@@ -13,22 +16,53 @@
* label = @Translation("Advanced Tab Dialog")
* )
*/
class CKEditorAdvancedTab extends CKEditorPluginBase {
class CKEditorAdvancedTab extends CKEditorPluginBase implements ContainerFactoryPluginInterface {
/**
* {@inheritdoc}
* The logger service.
*
* @var \Psr\Log\LoggerInterface
*/
public function getFile() {
protected $logger;
$path = 'libraries/ckeditor/plugins/dialogadvtab/plugin.js';
/**
* Constructs a new CKEditorAdvancedTab object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->logger = $logger;
}
if (file_exists($path)) {
return 'libraries/ckeditor/plugins/dialogadvtab/plugin.js';
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('logger.channel.ckeditor_advanced_tab'));
}
/**
* {@inheritdoc}
*/
public function getFile() {
$file = 'libraries/ckeditor/plugins/dialogadvtab/plugin.js';
if (!file_exists($file)) {
$this->logger->error(t(
'The %file file cannot be found. Please follow the installation instructions given in the README.md file.',
['%file' => $file]
));
}
else {
drupal_set_message(t("The plugin.js file can't be found in libraries/ckeditor/plugins/dialogadvtab. Please check README for installation."), 'error');
return $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