final class ApiProductEntityAccessCacheReset in Apigee Edge 8
Ensures that entity access cache gets cleared on API product entities.
Hierarchy
- class \Drupal\apigee_edge\EventSubscriber\ApiProductEntityAccessCacheReset implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ApiProductEntityAccessCacheReset
1 string reference to 'ApiProductEntityAccessCacheReset'
1 service uses ApiProductEntityAccessCacheReset
File
- src/
EventSubscriber/ ApiProductEntityAccessCacheReset.php, line 35
Namespace
Drupal\apigee_edge\EventSubscriberView source
final class ApiProductEntityAccessCacheReset implements EventSubscriberInterface {
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
private $entityTypeManager;
/**
* ApiProductEntityAccessCacheReset constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
// Reset API product access when a app credentials gets
// updated because having an app with a product grants access
// to the product.
// @see _apigee_edge_user_has_an_app_with_product()
AppCredentialCreateEvent::EVENT_NAME => 'clearApiProductCache',
AppCredentialGenerateEvent::EVENT_NAME => 'clearApiProductCache',
AppCredentialDeleteEvent::EVENT_NAME => 'clearApiProductCache',
AppCredentialAddApiProductEvent::EVENT_NAME => 'clearApiProductCache',
AppCredentialDeleteApiProductEvent::EVENT_NAME => 'clearApiProductCache',
];
}
/**
* Clears API product entity access cache.
*
* @param \Symfony\Component\EventDispatcher\Event $event
* Event that triggered this subscriber.
*/
public function clearApiProductCache(Event $event) : void {
$this->entityTypeManager
->getAccessControlHandler('api_product')
->resetCache();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ApiProductEntityAccessCacheReset:: |
private | property | The entity type manager service. | |
ApiProductEntityAccessCacheReset:: |
public | function | Clears API product entity access cache. | |
ApiProductEntityAccessCacheReset:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ApiProductEntityAccessCacheReset:: |
public | function | ApiProductEntityAccessCacheReset constructor. |