You are here

public function DrupalGapController::drupalgapResourceSystemSiteSettings in DrupalGap 8.2

Returns a collection of variables from the current Drupal site.

Return value

array Array of variables from the configuration.

File

src/Controller/DrupalGapController.php, line 224
Contains \Drupal\drupalgap\Controller\DrupalGapController.

Class

DrupalGapController
Returns responses for DrupalGap module routes.

Namespace

Drupal\drupalgap\Controller

Code

public function drupalgapResourceSystemSiteSettings() {

  // Config names.
  $names = array(
    // @TODO for the moment only working for 'user_register'

    /*'admin_theme',
      'clean_url',
      'date_default_timezone',
      'site_name',
      'theme_default',
      'user_pictures',
      'user_email_verification',*/
    'user.settings' => array(
      'register',
    ),
  );

  // Invoke hook_drupalgap_site_settings() to let others specify variable names
  // to use.
  if (sizeof(\Drupal::moduleHandler()
    ->getImplementations('drupalgap_site_settings')) > 0) {
    \Drupal::moduleHandler()
      ->invokeAll('drupalgap_site_settings', $names);
  }

  // Now fetch the values.
  $settings = new \stdClass();
  foreach ($names as $settingKeys => $settingKey) {
    foreach ($settingKey as $name) {
      $value = \Drupal::config($settingKeys)
        ->get($name);
      $settings->variable = new \stdClass();
      $settings->variable->{$name} = $value;
    }
  }

  // Add Drupal core version into settings.
  $settings->variable->drupal_core = "8";
  return $settings->variable;
}