You are here

private static function InsertViewDialog::getFieldInfo in Advanced Insert View 8

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

Get the field info to have some labels and description for argument in dialog form

Parameters

$argument:

Return value

array

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

File

src/Form/InsertViewDialog.php, line 73

Class

InsertViewDialog
Class InsertViewDialog

Namespace

Drupal\insert_view_adv\Form

Code

private static function getFieldInfo($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,
  ];
}