Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Process / TextFormat.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Process\TextFormat.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Process;
8
9 use Drupal\bootstrap\Annotation\BootstrapProcess;
10 use Drupal\bootstrap\Bootstrap;
11 use Drupal\bootstrap\Utility\Element;
12 use Drupal\Core\Form\FormStateInterface;
13
14 /**
15  * Processes the "text_format" element.
16  *
17  * @ingroup plugins_process
18  *
19  * @BootstrapProcess("text_format")
20  *
21  * @see \Drupal\filter\Element\TextFormat::processFormat()
22  */
23 class TextFormat extends ProcessBase implements ProcessInterface {
24
25   /**
26    * {@inheritdoc}
27    */
28   public static function processElement(Element $element, FormStateInterface $form_state, array &$complete_form) {
29     if (isset($element->format)) {
30       $element->format->addClass('form-inline');
31
32       // Guidelines (removed).
33       $element->format->guidelines->setProperty('access', FALSE);
34
35       // Format (select).
36       $element->format->format
37         ->addClass('input-sm')
38         ->setProperty('title_display', 'invisible')
39         ->setProperty('weight', -10);
40
41       // Help (link).
42       $element->format->help->about
43         ->setAttribute('title', t('Opens in new window'))
44         ->setProperty('icon', Bootstrap::glyphicon('question-sign'));
45       if (Bootstrap::getTheme()->getSetting('tooltip_enabled')) {
46         $element->format->help->about->setAttribute('data-toggle', 'tooltip');
47       }
48     }
49   }
50
51 }