You are here

protected function InsertFileWidgetUtility::getFieldDefinitions in Insert 8

Parameters

array $element:

FormStateInterface $form_state:

Return value

\Drupal\Core\Field\FieldDefinitionInterface[]|null

1 call to InsertFileWidgetUtility::getFieldDefinitions()
InsertFileWidgetUtility::process in src/Utility/InsertFileWidgetUtility.php
Form API callback: Processes a file field element.

File

src/Utility/InsertFileWidgetUtility.php, line 266

Class

InsertFileWidgetUtility

Namespace

Drupal\insert\Utility

Code

protected function getFieldDefinitions($element, $form_state) {
  $bundle = FALSE;
  $formObject = $form_state
    ->getFormObject();
  if ($formObject instanceof ContentEntityForm) {
    $bundle = $formObject
      ->getEntity()
      ->bundle();
  }
  if (!$bundle) {
    return null;
  }

  /** @var \Drupal\Core\Entity\EntityFieldManager $entityFieldManager */
  $entityFieldManager = \Drupal::service('entity_field.manager');
  return $entityFieldManager
    ->getFieldDefinitions($element['#entity_type'], $bundle);
}