class AvatarKitCommonService in Avatar Kit 8.2
Same name in this branch
- 8.2 src/Plugin/Derivative/AvatarKitCommonService.php \Drupal\avatars\Plugin\Derivative\AvatarKitCommonService
- 8.2 src/Plugin/Avatars/Service/AvatarKitCommonService.php \Drupal\avatars\Plugin\Avatars\Service\AvatarKitCommonService
Creates services for each Avatar Kit library service.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\avatars\Plugin\Derivative\AvatarKitCommonService implements ContainerDeriverInterface
Expanded class hierarchy of AvatarKitCommonService
File
- src/
Plugin/ Derivative/ AvatarKitCommonService.php, line 13
Namespace
Drupal\avatars\Plugin\DerivativeView source
class AvatarKitCommonService extends DeriverBase implements ContainerDeriverInterface {
/**
* The base plugin ID this derivative is for.
*
* @var string
*/
protected $basePluginId;
/**
* Avatar Kit service discovery.
*
* @var \dpi\ak\AvatarServiceDiscoveryInterface
*/
protected $avatarKitServiceDiscovery;
/**
* Constructs an EntityDeriver object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \dpi\ak\AvatarServiceDiscoveryInterface $avatarKitServiceDiscovery
* Avatar Kit service discovery.
*/
public function __construct($base_plugin_id, AvatarServiceDiscoveryInterface $avatarKitServiceDiscovery) {
$this->basePluginId = $base_plugin_id;
$this->avatarKitServiceDiscovery = $avatarKitServiceDiscovery;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('avatars.avatar_kit.discovery.services'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) : array {
$services = $this->avatarKitServiceDiscovery
->getAvatarServices();
foreach ($services as $service) {
$id = $service->id;
$this->derivatives[$id] = $base_plugin_definition;
$this->derivatives[$id]['label'] = $service->name;
$this->derivatives[$id]['description'] = $service->description;
}
return $this->derivatives;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AvatarKitCommonService:: |
protected | property | Avatar Kit service discovery. | |
AvatarKitCommonService:: |
protected | property | The base plugin ID this derivative is for. | |
AvatarKitCommonService:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
AvatarKitCommonService:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
AvatarKitCommonService:: |
public | function | Constructs an EntityDeriver object. | |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |