Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::config()
  2. 9 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::config()

Retrieves a configuration object.

This is the main entry point to the configuration API. Calling

$this
  ->config('my_module.admin');

will return a configuration object in which the my_module module can store its administrative settings.

Parameters

string $name: The name of the configuration object to retrieve. The name corresponds to a configuration file. For

\Drupal::config('my_module.admin');

, the config object returned will contain the contents of my_module.admin configuration file.

Return value

\Drupal\Core\Config\Config A configuration object.

11 calls to ControllerBase::config()
BlockListController::listing in core/modules/block/src/Controller/BlockListController.php
Shows the block administration page.
ContactController::contactSitePage in core/modules/contact/src/Controller/ContactController.php
Presents the site-wide contact form.
ForumController::addContainer in core/modules/forum/src/Controller/ForumController.php
Returns add container entity form.
ForumController::addForum in core/modules/forum/src/Controller/ForumController.php
Returns add forum entity form.
ForumController::build in core/modules/forum/src/Controller/ForumController.php
Returns a renderable forum index page array.

... See full list

File

core/lib/Drupal/Core/Controller/ControllerBase.php, line 162

Class

ControllerBase
Utility base class for thin controllers.

Namespace

Drupal\Core\Controller

Code

protected function config($name) {
  if (!$this->configFactory) {
    $this->configFactory = $this
      ->container()
      ->get('config.factory');
  }
  return $this->configFactory
    ->get($name);
}