InsertFileWidget.php in Insert 8
File
src/Plugin/Field/FieldWidget/InsertFileWidget.php
View source
<?php
namespace Drupal\insert\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Plugin\Field\FieldWidget\FileWidget;
use Drupal\insert\Utility\InsertFileWidgetUtility;
class InsertFileWidget extends FileWidget {
protected static $util;
protected static function util() {
if (self::$util === null) {
self::$util = new InsertFileWidgetUtility();
}
return self::$util;
}
public static function defaultSettings() {
return self::util()
->defaultSettings() + parent::defaultSettings();
}
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
return self::util()
->settingsForm($element, $this
->getSettings());
}
public static function validateStyles($element, &$form_state) {
self::util()
->validateStyles($element, $form_state);
}
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
$element = self::util()
->formElement($element, $this
->getSettings());
return $element;
}
public static function process($element, FormStateInterface $form_state, $form) {
$originalElement = $element;
$element = self::util()
->process($element, $form_state);
return $element === null ? parent::process($originalElement, $form_state, $form) : parent::process($element, $form_state, $form);
}
}
Classes
Name |
Description |
InsertFileWidget |
Plugin implementation of the Insert File widget.
This is just a barebone set of overwritten methods. All actual logic is
deferred to \Drupal\insert\Utility\Utility as that may be overwritten in
other Insert widgets covering other field types. |