You are here

function vertical_tabs_config_get_config in Vertical Tabs Config 8

Same name and namespace in other branches
  1. 7 vertical_tabs_config.module \vertical_tabs_config_get_config()

Returns module visibility configuration or -1.

2 calls to vertical_tabs_config_get_config()
vertical_tabs_config_form_node_form_alter in ./vertical_tabs_config.module
Implements hook_form_BASE_FORM_ID_alter().
VisibilityConfigurationForm::buildForm in src/Form/VisibilityConfigurationForm.php
Form constructor.

File

./vertical_tabs_config.module, line 146
Vertical tabs config main file.

Code

function vertical_tabs_config_get_config() {
  try {
    $query = Database::getConnection()
      ->select('vertical_tabs_config', 'n');
    $query
      ->fields('n', [
      'id',
      'vertical_tab',
      'content_type',
      'roles',
      'hidden',
    ]);
    $result = $query
      ->execute()
      ->fetchAll();
  } catch (Exception $e) {
    \Drupal::logger('vertical_tabs_config')
      ->notice($e
      ->getMessage());
    return "-1";
  }
  if (isset($result) && is_array($result)) {
    $conf_hash = [];
    foreach ($result as $obj) {
      $conf_hash[$obj->content_type][$obj->vertical_tab] = $obj->hidden;
      if (!isset($conf_hash[$obj->content_type]['roles'])) {
        $conf_hash[$obj->content_type]['roles'] = json_decode($obj->roles);
      }
    }
    return $conf_hash;
  }
  else {
    return "-1";
  }
}