abstract class MediaTypeBase in Media entity 8
Base implementation of media type plugin.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\media_entity\MediaTypeBase implements ContainerFactoryPluginInterface, MediaTypeInterface uses StringTranslationTrait
Expanded class hierarchy of MediaTypeBase
1 file declares its use of MediaTypeBase
- Generic.php in src/
Plugin/ MediaEntity/ Type/ Generic.php
File
- src/
MediaTypeBase.php, line 18
Namespace
Drupal\media_entityView source
abstract class MediaTypeBase extends PluginBase implements MediaTypeInterface, ContainerFactoryPluginInterface {
use StringTranslationTrait;
/**
* Plugin label.
*
* @var string
*/
protected $label;
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface;
*/
protected $entityTypeManager;
/**
* The entity field manager service.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface;
*/
protected $entityFieldManager;
/**
* Media entity image config object.
*
* @var \Drupal\Core\Config\Config
*/
protected $config;
/**
* Constructs a new class instance.
*
* @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 \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager service.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* Entity field manager service.
* @param \Drupal\Core\Config\Config $config
* Media entity config object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, Config $config) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
$this->entityFieldManager = $entity_field_manager;
$this->config = $config;
$this
->setConfiguration($configuration);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'), $container
->get('entity_field.manager'), $container
->get('config.factory')
->get('media_entity.settings'));
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = NestedArray::mergeDeep($this
->defaultConfiguration(), $configuration);
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function getDefaultThumbnail() {
return '';
}
/**
* {@inheritdoc}
*/
public function label() {
return $this->label;
}
/**
* {@inheritdoc}
*/
public function attachConstraints(MediaInterface $media) {
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return [];
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function getDefaultName(MediaInterface $media) {
return 'media:' . $media
->bundle() . ':' . $media
->uuid();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaTypeBase:: |
protected | property | Media entity image config object. | |
MediaTypeBase:: |
protected | property | The entity field manager service. | |
MediaTypeBase:: |
protected | property | The entity type manager service. | |
MediaTypeBase:: |
protected | property | Plugin label. | |
MediaTypeBase:: |
public | function |
Attaches type-specific constraints to media. Overrides MediaTypeInterface:: |
|
MediaTypeBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
1 |
MediaTypeBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
MediaTypeBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
MediaTypeBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurablePluginInterface:: |
1 |
MediaTypeBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurablePluginInterface:: |
|
MediaTypeBase:: |
public | function |
Provide a default name for the media. Overrides MediaTypeInterface:: |
|
MediaTypeBase:: |
public | function |
Gets the default thumbnail image. Overrides MediaTypeInterface:: |
|
MediaTypeBase:: |
public | function |
Returns the display label. Overrides MediaTypeInterface:: |
|
MediaTypeBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurablePluginInterface:: |
|
MediaTypeBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
MediaTypeBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
MediaTypeBase:: |
public | function |
Constructs a new class instance. Overrides PluginBase:: |
|
MediaTypeInterface:: |
public | function | Gets a media-related field/value. | 1 |
MediaTypeInterface:: |
public | function | Gets list of fields provided by this plugin. | 1 |
MediaTypeInterface:: |
public | function | Gets thumbnail image. | 1 |
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. | |
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. |