final class DeveloperAppCacheFactory in Apigee Edge 8
Developer specific app cache by app owner factory service.
This service ensures that the same cache instance is being used for the same developer's developer apps even if the developer is sometimes referenced by its UUID and sometimes by its email address.
Hierarchy
- class \Drupal\apigee_edge\Entity\Controller\Cache\DeveloperAppCacheFactory implements AppCacheByOwnerFactoryInterface
Expanded class hierarchy of DeveloperAppCacheFactory
1 string reference to 'DeveloperAppCacheFactory'
1 service uses DeveloperAppCacheFactory
File
- src/
Entity/ Controller/ Cache/ DeveloperAppCacheFactory.php, line 34
Namespace
Drupal\apigee_edge\Entity\Controller\CacheView source
final class DeveloperAppCacheFactory implements AppCacheByOwnerFactoryInterface {
/**
* The (general) app cache by owner factory.
*
* @var \Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerFactoryInterface
*/
private $appCacheByOwnerFactory;
/**
* The email validator service.
*
* @var \Drupal\Component\Utility\EmailValidatorInterface
*/
private $emailValidator;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
private $entityTypeManager;
/**
* DeveloperAppCacheFactory constructor.
*
* @param \Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerFactoryInterface $app_cache_by_owner_factory
* The (general) app cache by owner factory.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Component\Utility\EmailValidatorInterface $email_validator
* The email validator service.
*/
public function __construct(AppCacheByOwnerFactoryInterface $app_cache_by_owner_factory, EntityTypeManagerInterface $entity_type_manager, EmailValidatorInterface $email_validator) {
$this->appCacheByOwnerFactory = $app_cache_by_owner_factory;
$this->emailValidator = $email_validator;
$this->entityTypeManager = $entity_type_manager;
}
/**
* Returns the same app cache instance for a developer.
*
* Even if the owner is sometime a UUID and sometime an email address.
*
* @param string $owner
* Developer id (UUID) or email.
*
* @return \Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerInterface
* The developer app cache that belongs to this owner.
*/
public function getAppCache(string $owner) : AppCacheByOwnerInterface {
if ($this->emailValidator
->isValid($owner)) {
/** @var \Drupal\apigee_edge\Entity\Developer|null $developer */
$developer = $this->entityTypeManager
->getStorage('developer')
->load($owner);
if ($developer === NULL) {
throw new DeveloperDoesNotExistException($owner);
}
$owner = $developer
->getDeveloperId();
}
return $this->appCacheByOwnerFactory
->getAppCache($owner);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeveloperAppCacheFactory:: |
private | property | The (general) app cache by owner factory. | |
DeveloperAppCacheFactory:: |
private | property | The email validator service. | |
DeveloperAppCacheFactory:: |
private | property | The entity type manager. | |
DeveloperAppCacheFactory:: |
public | function |
Returns the same app cache instance for a developer. Overrides AppCacheByOwnerFactoryInterface:: |
|
DeveloperAppCacheFactory:: |
public | function | DeveloperAppCacheFactory constructor. |