You are here

protected function FieldEncryptProcessEntities::checkField in Field Encryption 8.2

Check if a given field has encryption enabled.

Parameters

\Drupal\Core\Field\FieldItemListInterface $field: The field to check.

Return value

bool Boolean indicating whether to encrypt the field.

4 calls to FieldEncryptProcessEntities::checkField()
FieldEncryptProcessEntities::entityHasEncryptedFields in src/FieldEncryptProcessEntities.php
Check if entity has encrypted fields.
FieldEncryptProcessEntities::getUncacheableFields in src/FieldEncryptProcessEntities.php
Get field names for an entity that are set to be excluded from cache.
FieldEncryptProcessEntities::processField in src/FieldEncryptProcessEntities.php
Process a field.
FieldEncryptProcessEntities::updateStoredField in src/FieldEncryptProcessEntities.php
Update the encryption settings on a stored field.

File

src/FieldEncryptProcessEntities.php, line 207

Class

FieldEncryptProcessEntities
Service class to process entities and fields for encryption.

Namespace

Drupal\field_encrypt

Code

protected function checkField(FieldItemListInterface $field) {
  if (!is_callable([
    $field,
    'getFieldDefinition',
  ])) {
    return FALSE;
  }

  /* @var $definition \Drupal\Core\Field\BaseFieldDefinition */
  $definition = $field
    ->getFieldDefinition();
  if (!is_callable([
    $definition,
    'get',
  ])) {
    return FALSE;
  }

  /* @var $storage \Drupal\Core\Field\FieldConfigStorageBase */
  $storage = $definition
    ->get('fieldStorage');
  if (is_null($storage)) {
    return FALSE;
  }

  // Check if the field is encrypted.
  $encrypted = $storage
    ->getThirdPartySetting('field_encrypt', 'encrypt', FALSE);
  if ($encrypted) {
    return TRUE;
  }
  return FALSE;
}