public function EncryptedFieldValueManager::getExistingEntity in Field Encryption 8.2
Loads an existing EncryptedFieldValue entity.
@fixme have its own custom method ...
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to check.
string $field_name: The field name to check.
int $delta: The field delta to check.
string $property: The field property to check.
Return value
bool|\Drupal\field_encrypt\Entity\EncryptedFieldValue The existing EncryptedFieldValue entity.
Overrides EncryptedFieldValueManagerInterface::getExistingEntity
2 calls to EncryptedFieldValueManager::getExistingEntity()
- EncryptedFieldValueManager::createEncryptedFieldValue in src/
EncryptedFieldValueManager.php - Create an encrypted field value, or update an existing one.
- EncryptedFieldValueManager::getEncryptedFieldValue in src/
EncryptedFieldValueManager.php - Get an encrypted field value.
File
- src/
EncryptedFieldValueManager.php, line 96
Class
- EncryptedFieldValueManager
- Manager containing common functions to manage EncryptedFieldValue entities.
Namespace
Drupal\field_encryptCode
public function getExistingEntity(ContentEntityInterface $entity, $field_name, $delta, $property) {
$query = $this->entityManager
->getStorage('encrypted_field_value')
->getQuery()
->condition('entity_type', $entity
->getEntityTypeId())
->condition('entity_id', $entity
->id())
->condition('entity_revision_id', $this
->getEntityRevisionId($entity))
->condition('langcode', $entity
->language()
->getId())
->condition('field_name', $field_name)
->condition('field_delta', $delta)
->condition('field_property', $property);
$values = $query
->execute();
if (!empty($values)) {
$id = array_shift($values);
return EncryptedFieldValue::load($id);
}
return FALSE;
}