You are here

function _minisite_get_fields in Mini site 8

Get Minisite fields from the entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Entity to get fields from.

Return value

array Array of Minisite field names.

1 call to _minisite_get_fields()
minisite_path_insert in ./minisite.module
Implements hook_path_insert().

File

./minisite.module, line 202
Main functions of the Minisite module.

Code

function _minisite_get_fields(EntityInterface $entity) {
  if (!$entity instanceof FieldableEntityInterface) {
    return [];
  }

  /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
  $entity_field_manager = Drupal::service('entity_field.manager');

  /** @var \Drupal\Core\Field\FieldDefinitionInterface[] $minisite_fields */
  return array_filter($entity_field_manager
    ->getFieldDefinitions($entity
    ->getEntityTypeId(), $entity
    ->bundle()), function (FieldDefinitionInterface $field_definition) {
    return $field_definition
      ->getType() == 'minisite';
  });
}