LlamaContextual.php

Same filename in other branches
  1. 9 core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextual.php

Namespace

Drupal\ckeditor_test\Plugin\CKEditorPlugin

File

core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextual.php

View source
<?php

namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;

use Drupal\ckeditor\CKEditorPluginContextualInterface;
use Drupal\editor\Entity\Editor;

/**
 * Defines a "Llama" plugin, with a contextually enabled "llama" feature.
 *
 * @CKEditorPlugin(
 *   id = "llama_contextual",
 *   label = @Translation("Contextual Llama")
 * )
 */
class LlamaContextual extends Llama implements CKEditorPluginContextualInterface {
    
    /**
     * {@inheritdoc}
     */
    public function isEnabled(Editor $editor) {
        // Automatically enable this plugin if the Underline button is enabled.
        $settings = $editor->getSettings();
        foreach ($settings['toolbar']['rows'] as $row) {
            foreach ($row as $group) {
                if (in_array('Strike', $group['items'])) {
                    return TRUE;
                }
            }
        }
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getFile() {
        return drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual.js';
    }

}

Classes

Title Deprecated Summary
LlamaContextual Defines a "Llama" plugin, with a contextually enabled "llama" feature.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.