YoutubePlugin.php in CKEditor Youtube 8
File
src/Plugin/CKEditorPlugin/YoutubePlugin.php
View source
<?php
namespace Drupal\ckeditor_youtube\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\editor\Entity\Editor;
class YoutubePlugin extends CKEditorPluginBase implements ContainerFactoryPluginInterface {
protected $configFactory;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config_factory;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
public function getButtons() {
return [
'Youtube' => [
'label' => $this
->t('YouTube'),
'image' => $this
->getYoutubeLibraryPath() . '/images/icon.png',
],
];
}
public function isInternal() {
return FALSE;
}
public function getDependencies(Editor $editor) {
return [];
}
public function getLibraries(Editor $editor) {
return [];
}
public function getFile() {
return $this
->getYoutubeLibraryPath() . '/plugin.js';
}
public function getConfig(Editor $editor) {
return [];
}
private function getYoutubeLibraryPath() {
$config = $this->configFactory
->get('ckeditor_youtube.settings');
return $config
->get('library_path');
}
}