You are here

protected function AvatarKitCommonService::getService in Avatar Kit 8.2

Create a service instance.

Return value

\dpi\ak\AvatarKit\AvatarServices\AvatarServiceInterface A new service instance

File

src/Plugin/Avatars/Service/AvatarKitCommonService.php, line 106

Class

AvatarKitCommonService
Automatically creates services based on plugins from Avatar Kit library.

Namespace

Drupal\avatars\Plugin\Avatars\Service

Code

protected function getService() {
  $configuration = $this
    ->newAvatarConfiguration();
  $width = $this->configuration['width'] ?? NULL;
  if (is_int($width)) {
    $configuration
      ->setWidth($width);
  }
  $height = $this->configuration['height'] ?? NULL;
  if (is_int($height)) {
    $configuration
      ->setHeight($height);
  }
  $protocol = $this->configuration['protocol'] ?? NULL;
  if (!empty($protocol)) {
    $configuration
      ->setProtocol($protocol);
  }
  return $this
    ->createService($configuration);
}