class FormEntityProfileTypeDeriver in Flexiform 8
Provides a deriver class.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\flexiform\Plugin\Deriver\FormEntityProfileTypeDeriver implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of FormEntityProfileTypeDeriver
File
- src/
Plugin/ Deriver/ FormEntityProfileTypeDeriver.php, line 17
Namespace
Drupal\flexiform\Plugin\DeriverView source
class FormEntityProfileTypeDeriver extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The entity bundle info manager.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityBundleInfo;
/**
* Constructs new EntityViewDeriver.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_bundle_info
* The entity bundle info service.
*/
public function __construct(EntityTypeManagerInterface $entity_manager, TranslationInterface $string_translation, EntityTypeBundleInfoInterface $entity_bundle_info) {
$this->entityBundleInfo = $entity_bundle_info;
$this->entityTypeManager = $entity_manager;
$this->stringTranslation = $string_translation;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'), $container
->get('string_translation'), $container
->get('entity_type.bundle.info'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
if (!\Drupal::moduleHandler()
->moduleExists('profile')) {
return [];
}
$entity_type = $this->entityTypeManager
->getDefinition('profile');
foreach ($this->entityBundleInfo
->getBundleInfo('profile') as $bundle => $bundle_info) {
$plugin_id = $bundle;
$this->derivatives[$plugin_id] = [
'label' => $this
->t('@bundle @profile from User', [
'@bundle' => $bundle_info['label'],
'@profile' => $entity_type
->getLabel(),
]),
'profile_type' => $bundle,
'context' => [
'user' => new ContextDefinition('entity:user', $this
->t('Base User')),
],
] + $base_plugin_definition;
}
return $this->derivatives;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
FormEntityProfileTypeDeriver:: |
protected | property | The entity bundle info manager. | |
FormEntityProfileTypeDeriver:: |
protected | property | The entity manager. | |
FormEntityProfileTypeDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
FormEntityProfileTypeDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
FormEntityProfileTypeDeriver:: |
public | function | Constructs new EntityViewDeriver. | |
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. |