abstract class DisplayBase in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/DisplayBase.php \Drupal\entity_browser\DisplayBase
Base implementation for display plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\entity_browser\DisplayBase implements ContainerFactoryPluginInterface, DisplayInterface uses PluginConfigurationFormTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of DisplayBase
3 files declare their use of DisplayBase
- IFrame.php in src/
Plugin/ EntityBrowser/ Display/ IFrame.php - Modal.php in src/
Plugin/ EntityBrowser/ Display/ Modal.php - Standalone.php in src/
Plugin/ EntityBrowser/ Display/ Standalone.php
File
- src/
DisplayBase.php, line 19
Namespace
Drupal\entity_browserView source
abstract class DisplayBase extends PluginBase implements DisplayInterface, ContainerFactoryPluginInterface {
use PluginConfigurationFormTrait;
/**
* Plugin label.
*
* @var string
*/
protected $label;
/**
* Selected entities.
*
* @var \Drupal\Core\Entity\EntityInterface[]
*/
protected $entities = [];
/**
* Event dispatcher service.
*
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
protected $eventDispatcher;
/**
* UUID generator interface.
*
* @var \Drupal\Component\Uuid\UuidInterface
*/
protected $uuidGenerator;
/**
* Instance UUID string.
*
* @var string
*/
protected $uuid = NULL;
/**
* The selection storage.
*
* @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface
*/
protected $selectionStorage;
/**
* Constructs display plugin.
*
* @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 \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* Event dispatcher service.
* @param \Drupal\Component\Uuid\UuidInterface $uuid_generator
* UUID generator interface.
* @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $selection_storage
* The selection storage.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, UuidInterface $uuid_generator, KeyValueStoreExpirableInterface $selection_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
$this->eventDispatcher = $event_dispatcher;
$this->uuidGenerator = $uuid_generator;
$this->selectionStorage = $selection_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('event_dispatcher'), $container
->get('uuid'), $container
->get('entity_browser.selection_storage'));
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return array_diff_key($this->configuration, [
'entity_browser_id' => 0,
]);
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = NestedArray::mergeDeep($this
->defaultConfiguration(), $configuration);
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [];
}
/**
* {@inheritdoc}
*/
public function label() {
return $this->label;
}
/**
* {@inheritdoc}
*/
public function getUuid() {
if (empty($this->uuid)) {
$this->uuid = $this->uuidGenerator
->generate();
}
return $this->uuid;
}
/**
* {@inheritdoc}
*/
public function setUuid($uuid) {
$this->uuid = $uuid;
}
/**
* {@inheritdoc}
*/
public function displayEntityBrowser(array $element, FormStateInterface $form_state, array &$complete_form, array $persistent_data = []) {
// Store persistent data so that after being rendered widgets can still
// have access to contextual information.
$this->selectionStorage
->setWithExpire($this
->getUuid(), $persistent_data, Settings::get('entity_browser_expire', 21600));
}
/**
* {@inheritdoc}
*/
public function selectionCompleted(array $entities) {
$this->entities = $entities;
$this->eventDispatcher
->addListener(KernelEvents::RESPONSE, [
$this,
'propagateSelection',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
DisplayBase:: |
protected | property | Selected entities. | |
DisplayBase:: |
protected | property | Event dispatcher service. | |
DisplayBase:: |
protected | property | Plugin label. | |
DisplayBase:: |
protected | property | The selection storage. | |
DisplayBase:: |
protected | property | Instance UUID string. | |
DisplayBase:: |
protected | property | UUID generator interface. | |
DisplayBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
DisplayBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
DisplayBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
2 |
DisplayBase:: |
public | function |
Displays entity browser. Overrides DisplayInterface:: |
2 |
DisplayBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
DisplayBase:: |
public | function |
Gets the uuid for this display. Overrides DisplayInterface:: |
|
DisplayBase:: |
public | function |
Returns the display label. Overrides DisplayInterface:: |
|
DisplayBase:: |
public | function |
Indicates completed selection. Overrides DisplayInterface:: |
1 |
DisplayBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
DisplayBase:: |
public | function |
Sets the uuid for this display. Overrides DisplayInterface:: |
|
DisplayBase:: |
public | function |
Constructs display plugin. Overrides PluginBase:: |
1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginConfigurationFormTrait:: |
public | function | Implements PluginFormInterface::buildConfigurationForm(). | 5 |
PluginConfigurationFormTrait:: |
public | function | Implements PluginFormInterface::submitConfigurationForm(). | 3 |
PluginConfigurationFormTrait:: |
public | function | Implements PluginFormInterface::validateConfigurationForm(). | 2 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |