public function EntityEmbedDisplayManager::createInstance in Entity Embed 8
Creates a pre-configured instance of a plugin.
Parameters
string $plugin_id: The ID of the plugin being instantiated.
array $configuration: An array of configuration relevant to the plugin instance.
Return value
object A fully configured plugin instance.
Throws
\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.
Overrides PluginManagerBase::createInstance
1 call to EntityEmbedDisplayManager::createInstance()
- EntityEmbedDisplayManager::getDefinitionsForContexts in src/
EntityEmbedDisplay/ EntityEmbedDisplayManager.php - Determines plugins whose constraints are satisfied by a set of contexts.
File
- src/
EntityEmbedDisplay/ EntityEmbedDisplayManager.php, line 175
Class
- EntityEmbedDisplayManager
- Provides an Entity Embed display plugin manager.
Namespace
Drupal\entity_embed\EntityEmbedDisplayCode
public function createInstance($plugin_id, array $configuration = []) {
$instance = parent::createInstance($plugin_id, $configuration);
$definition = $instance
->getPluginDefinition();
if (empty($definition['supports_image_alt_and_title'])) {
return $instance;
}
else {
// Use decorator pattern to add alt and title fields to dialog when
// embedding media with image source.
return new MediaImageDecorator($instance);
}
}