apiKey = $apiKey; } public function afterSave(Entity $entity) { if (!$entity->isApi()) { return; } if ( $entity->get('apiKey') && $entity->get('secretKey') && ( $entity->isAttributeChanged('apiKey') || $entity->isAttributeChanged('authMethod') ) ) { $this->apiKey->storeSecretKeyForUserId($entity->id, $entity->get('secretKey')); } if ( $entity->isAttributeChanged('authMethod') && $entity->get('authMethod') !== 'Hmac' ) { $this->apiKey->removeSecretKeyForUserId($entity->id); } } public function afterRemove(Entity $entity) { if (!$entity->isApi()) { return; } if ($entity->isApi() && $entity->get('authMethod') === 'Hmac') { $this->apiKey->removeSecretKeyForUserId($entity->id); } } }