You are here

private static function InsertViewDialog::getFieldInfo in Advanced Insert View 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/InsertViewDialog.php \Drupal\insert_view_adv\Form\InsertViewDialog::getFieldInfo()

Get the field info.

Gets labels and description for argument in dialog form.

Parameters

array $argument: Argument definition.

Return value

array Argument information.

1 call to InsertViewDialog::getFieldInfo()
InsertViewDialog::renderArgument in src/Form/InsertViewDialog.php
Create the argument field.

File

src/Form/InsertViewDialog.php, line 81

Class

InsertViewDialog
Class InsertViewDialog.

Namespace

Drupal\insert_view_adv\Form

Code

private static function getFieldInfo(array $argument) {
  $info = [];
  $bundle_info = [];
  $argument = array_shift($argument);
  if (!empty($argument['table'])) {
    $keys = explode('__', $argument['table']);
    if (!empty($keys[1])) {
      $info = FieldStorageConfig::loadByName($keys[0], $keys[1]);

      // If it is entity reference field try to get the target type and
      // selector settings.
      if ($info && $info
        ->getType() == 'entity_reference') {
        $bundles = $info
          ->getBundles();
        $bundles_machine_names = array_keys($bundles);
        $bundle_info = FieldConfig::loadByName($keys[0], $bundles_machine_names[0], $keys[1]);
      }
    }
  }
  return [
    'info' => $info,
    'bundle_info' => $bundle_info,
  ];
}