function public function Theme::getSettingPlugin

8.x-3.x Theme.php public Theme::getSettingPlugin($name = NULL, $rebuild = FALSE)

Retrieves a theme's setting plugin instance(s).


string $name: Optional. The name of a specific setting plugin instance to return.

bool $rebuild: Flag indicating whether to reset any cached definitions and rebuild the settings.

Return value

\Drupal\bootstrap\Plugin\Setting\SettingInterface|\Drupal\bootstrap\Plugin\Setting\SettingInterface[]|null If $name was provided, it will either return a specific setting plugin instance or NULL if not set. If $name was omitted it will return an array of setting plugin instances, keyed by their name.


Defines a theme object.



Source src/Theme.php (line 563)

public function getSettingPlugin($name = NULL, $rebuild = FALSE) {
  if (!isset($this->settings) || $rebuild) {
    $settings = [];
    if ($this->isBootstrap()) {
      $setting_manager = new SettingManager($this);
      if ($rebuild) {
      $plugin_ids = array_keys($setting_manager->getDefinitions());
      foreach ($plugin_ids as $plugin_id) {
        $settings[$plugin_id] = $setting_manager->createInstance($plugin_id);
    $this->settings = $settings;

  // Return a specific setting plugin.
  if (isset($name)) {
    return isset($this->settings[$name]) ? $this->settings[$name] : NULL;

  // Return all setting plugins.
  return $this->settings;