You are here

class DrupalResponsiveImageStyle in Inline responsive images 8.2

Defines the "drupalresponsiveimagestyle" plugin.

Plugin annotation


@CKEditorPlugin(
  id = "drupalresponsiveimagestyle",
  label = @Translation("Drupal responsive image style"),
  module = "inline_responsive_images"
)

Hierarchy

Expanded class hierarchy of DrupalResponsiveImageStyle

File

src/Plugin/CKEditorPlugin/DrupalResponsiveImageStyle.php, line 24
Contains \Drupal\inline_responsive_images\Plugin\CKEditorPlugin\DrupalResponsiveImageStyle.

Namespace

Drupal\inline_responsive_images\Plugin\CKEditorPlugin
View source
class DrupalResponsiveImageStyle extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface {

  /**
   * {@inheritdoc}
   */
  public function isInternal() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getDependencies(Editor $editor) {
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function getLibraries(Editor $editor) {
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function getFile() {
    return drupal_get_path('module', 'inline_responsive_images') . '/js/plugins/drupalresponsiveimagestyle/plugin.js';
  }

  /**
   * {@inheritdoc}
   */
  public function getConfig(Editor $editor) {
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function isEnabled(Editor $editor) {
    if (!$editor
      ->hasAssociatedFilterFormat()) {
      return FALSE;
    }

    // Automatically enable this plugin if the text format associated with this
    // text editor uses the filter_responsive_image_style filter and the
    // DrupalImage button is enabled.
    $format = $editor
      ->getFilterFormat();
    if ($format
      ->filters('filter_responsive_image_style')->status) {
      $enabled = FALSE;
      $settings = $editor
        ->getSettings();
      foreach ($settings['toolbar']['rows'] as $row) {
        foreach ($row as $group) {
          foreach ($group['items'] as $button) {
            if ($button === 'DrupalImage') {
              $enabled = TRUE;
            }
          }
        }
      }
      return $enabled;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalResponsiveImageStyle::getConfig public function Returns the additions to CKEDITOR.config for a specific CKEditor instance. Overrides CKEditorPluginInterface::getConfig
DrupalResponsiveImageStyle::getDependencies public function Returns a list of plugins this plugin requires. Overrides CKEditorPluginInterface::getDependencies
DrupalResponsiveImageStyle::getFile public function Returns the Drupal root-relative file path to the plugin JavaScript file. Overrides CKEditorPluginInterface::getFile
DrupalResponsiveImageStyle::getLibraries public function Returns a list of libraries this plugin requires. Overrides CKEditorPluginInterface::getLibraries
DrupalResponsiveImageStyle::isEnabled public function Checks if this plugin should be enabled based on the editor configuration. Overrides CKEditorPluginContextualInterface::isEnabled
DrupalResponsiveImageStyle::isInternal public function Indicates if this plugin is part of the optimized CKEditor build. Overrides CKEditorPluginInterface::isInternal
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92