private function DataPolicyConsentManager::createUserConsent in Data Policy 8
Create the user_consent entity.
Parameters
\Drupal\data_policy\Entity\DataPolicyInterface $data_policy: The data policy entity.
int $user_id: The user id.
int $state: The state for consent entity.
1 call to DataPolicyConsentManager::createUserConsent()
- DataPolicyConsentManager::saveConsent in src/
DataPolicyConsentManager.php - Save user consent.
File
- src/
DataPolicyConsentManager.php, line 352
Class
- DataPolicyConsentManager
- Defines the Data Policy Consent Manager service.
Namespace
Drupal\data_policyCode
private function createUserConsent(DataPolicyInterface $data_policy, $user_id, $state, $required) {
$this->entityTypeManager
->getStorage('user_consent')
->create()
->setRevision($data_policy)
->setOwnerId($user_id)
->set('state', $state)
->set('required', $required)
->save();
}