diff --git a/src/Plugin/CKEditorPlugin/MathJaxPlugin.php b/src/Plugin/CKEditorPlugin/MathJaxPlugin.php index bdfd952bf2a7a0e20513a9713e9386db62b1d140..15108e27e91d88fd51d26bca9b6a0c1808c8acc8 100644 --- a/src/Plugin/CKEditorPlugin/MathJaxPlugin.php +++ b/src/Plugin/CKEditorPlugin/MathJaxPlugin.php @@ -4,6 +4,7 @@ namespace Drupal\uw_cfg_common\Plugin\CKEditorPlugin; use Drupal\ckeditor\CKEditorPluginBase; use Drupal\editor\Entity\Editor; +use Drupal\Core\Asset\LibrariesDirectoryFileFinder; /** * Defines the "mathjax" plugin. @@ -15,6 +16,38 @@ use Drupal\editor\Entity\Editor; */ class MathJaxPlugin extends CKEditorPluginBase { + /** + * Library file finder. + * + * @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder + */ + protected $libFileFinder; + + /** + * Constructs a BlockComponentRenderArray 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 mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Asset\LibrariesDirectoryFileFinder $libFileFinder + * The library file finder. + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, LibrariesDirectoryFileFinder $libFileFinder) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->libFileFinder = $libFileFinder; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static($configuration, $plugin_id, $plugin_definition, $container->get('library.libraries_directory_file_finder')); + } + + /** * {@inheritdoc} */ @@ -47,10 +80,12 @@ class MathJaxPlugin extends CKEditorPluginBase { * {@inheritdoc} */ public function getButtons() { + $lib = $this->libFileFinder->find('ckeditor-mathjax'); + $path = \Drupal::service('file_system')->realpath($lib); return [ 'Mathjax' => [ 'label' => $this->t('Math'), - 'image' => drupal_get_path('profile', 'uw_base_profile') . '/libraries/ckeditor-mathjax/icons/mathjax.png', + 'image' => $path . '/icons/mathjax.png', ], ]; }