You are here

class Settings in Simple XML sitemap 4.x

Class Settings

Hierarchy

Expanded class hierarchy of Settings

16 files declare their use of Settings
CustomLinksForm.php in src/Form/CustomLinksForm.php
CustomUrlGenerator.php in src/Plugin/simple_sitemap/UrlGenerator/CustomUrlGenerator.php
EntityManager.php in src/Manager/EntityManager.php
EntityMenuLinkContentUrlGenerator.php in src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php
EntityUrlGenerator.php in src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php

... See full list

5 string references to 'Settings'
SettingsForm::buildForm in src/Form/SettingsForm.php
Form constructor.
simple_sitemap.links.menu.yml in ./simple_sitemap.links.menu.yml
simple_sitemap.links.menu.yml
simple_sitemap.links.task.yml in ./simple_sitemap.links.task.yml
simple_sitemap.links.task.yml
simple_sitemap.services.yml in ./simple_sitemap.services.yml
simple_sitemap.services.yml
simple_sitemap_engines.links.task.yml in modules/simple_sitemap_engines/simple_sitemap_engines.links.task.yml
modules/simple_sitemap_engines/simple_sitemap_engines.links.task.yml
1 service uses Settings
simple_sitemap.settings in ./simple_sitemap.services.yml
Drupal\simple_sitemap\Settings

File

src/Settings.php, line 10

Namespace

Drupal\simple_sitemap
View source
class Settings {

  /**
   * @var \Drupal\Core\Config\ConfigFactory
   */
  protected $configFactory;

  /**
   * SimpleSitemapSettings constructor.
   * @param \Drupal\Core\Config\ConfigFactory $config_factory
   */
  public function __construct(ConfigFactory $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * Returns a specific sitemap setting or a default value if setting does not
   * exist.
   *
   * @param string $name
   *  Name of the setting, like 'max_links'.
   * @param mixed $default
   *  Value to be returned if the setting does not exist in the configuration.
   *
   * @return mixed
   *  The current setting from configuration or a default value.
   */
  public function get(string $name, $default = FALSE) {

    // todo Why not NULL?
    $setting = $this->configFactory
      ->get('simple_sitemap.settings')
      ->get($name);
    return $setting ?? $default;
  }
  public function getAll() {
    return $this->configFactory
      ->get('simple_sitemap.settings')
      ->get();
  }

  /**
   * Stores a specific sitemap setting in configuration.
   *
   * @param string $name
   *  Setting name, like 'max_links'.
   * @param mixed $setting
   *  The setting to be saved.
   *
   * @return $this
   */
  public function save(string $name, $setting) : Settings {
    $this->configFactory
      ->getEditable('simple_sitemap.settings')
      ->set($name, $setting)
      ->save();
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Settings::$configFactory protected property
Settings::get public function Returns a specific sitemap setting or a default value if setting does not exist.
Settings::getAll public function
Settings::save public function Stores a specific sitemap setting in configuration.
Settings::__construct public function SimpleSitemapSettings constructor.