class FieldResultFunction in Votingapi Widgets 8
Deriver base class for field vote calculations.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\votingapi_widgets\Plugin\Derivative\FieldResultFunction implements ContainerDeriverInterface
Expanded class hierarchy of FieldResultFunction
File
- src/
Plugin/ Derivative/ FieldResultFunction.php, line 13
Namespace
Drupal\votingapi_widgets\Plugin\DerivativeView source
class FieldResultFunction extends DeriverBase implements ContainerDeriverInterface {
/**
* The entity field manager service.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager;
/**
* Constructs a FieldResultFunction instance.
*
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager.
*/
public function __construct(EntityFieldManagerInterface $entity_field_manager) {
$this->entityFieldManager = $entity_field_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_field.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$instances = $this->entityFieldManager
->getFieldMapByFieldType('voting_api_field');
$this->derivatives = [];
foreach ($instances as $entity_type => $fields) {
foreach (array_keys($fields) as $field_name) {
$plugin_id = $entity_type . '.' . $field_name;
$this->derivatives[$plugin_id] = $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:: |
|
FieldResultFunction:: |
protected | property | The entity field manager service. | |
FieldResultFunction:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
FieldResultFunction:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
FieldResultFunction:: |
public | function | Constructs a FieldResultFunction instance. |