You are here

function _paragraphs_grid_get_field_by_type in Paragraphs grid 8

Get active page field.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: The Entity which should be checked.

Return value

\Drupal\Core\Field\FieldItemListInterface|null Return the field or null.

1 call to _paragraphs_grid_get_field_by_type()
paragraphs_grid_preprocess_field in ./paragraphs_grid.module
Implements hook_preprocess_field().

File

./paragraphs_grid.module, line 177
Contains paragraphs_grid.module.

Code

function _paragraphs_grid_get_field_by_type(FieldableEntityInterface $entity, $type) {
  $fields = $entity
    ->getFields();
  foreach ($fields as $field) {
    $field_type = $field
      ->getFieldDefinition()
      ->getType();
    if ($field_type == $type) {
      return $field;
    }
  }
  return NULL;
}