You are here

protected function WorkflowFieldConstraintValidator::isValidFieldname in Workflow 8

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $field_storage:

Return value

bool

1 call to WorkflowFieldConstraintValidator::isValidFieldname()
WorkflowFieldConstraintValidator::validate in src/Plugin/Validation/Constraint/WorkflowFieldConstraintValidator.php
Checks if the passed value is valid.

File

src/Plugin/Validation/Constraint/WorkflowFieldConstraintValidator.php, line 69

Class

WorkflowFieldConstraintValidator
Validates the CommentName constraint.

Namespace

Drupal\workflow\Plugin\Validation\Constraint

Code

protected function isValidFieldname(FieldStorageDefinitionInterface $field_storage) {
  if ($field_storage
    ->getTargetEntityTypeId() !== 'comment') {
    return TRUE;
  }
  $field_name = $field_storage
    ->getName();

  // Check if the 'comment' field name exists on the 'commented' entity type.
  // @todo Fix field on a non-relevant entity_type.
  $comment_field_name_ok = FALSE;
  foreach (_workflow_info_fields() as $info) {
    if ($info
      ->getName() == $field_name && $info
      ->getTargetEntityTypeId() !== 'comment') {
      $comment_field_name_ok = TRUE;
    }
  }
  return $comment_field_name_ok;
}