You are here

class Config in Bamboo Twig 8.2

Same name and namespace in other branches
  1. 8.5 bamboo_twig_config/src/TwigExtension/Config.php \Drupal\bamboo_twig_config\TwigExtension\Config
  2. 8.3 bamboo_twig_config/src/TwigExtension/Config.php \Drupal\bamboo_twig_config\TwigExtension\Config
  3. 8.4 bamboo_twig_config/src/TwigExtension/Config.php \Drupal\bamboo_twig_config\TwigExtension\Config

Provides getter for configs drupal storage as Twig Extensions.

Hierarchy

  • class \Drupal\bamboo_twig\TwigExtension\TwigExtensionBase extends \Drupal\bamboo_twig\TwigExtension\Twig_Extension uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
    • class \Drupal\bamboo_twig_config\TwigExtension\Config

Expanded class hierarchy of Config

1 string reference to 'Config'
bamboo_twig_config.services.yml in bamboo_twig_config/bamboo_twig_config.services.yml
bamboo_twig_config/bamboo_twig_config.services.yml
1 service uses Config
bamboo_twig_config.twig.config in bamboo_twig_config/bamboo_twig_config.services.yml
Drupal\bamboo_twig_config\TwigExtension\Config

File

bamboo_twig_config/src/TwigExtension/Config.php, line 10

Namespace

Drupal\bamboo_twig_config\TwigExtension
View source
class Config extends TwigExtensionBase {

  /**
   * List of all Twig functions.
   */
  public function getFunctions() {
    return [
      new \Twig_SimpleFunction('bamboo_settings_get', [
        $this,
        'getSettings',
      ]),
      new \Twig_SimpleFunction('bamboo_config_get', [
        $this,
        'getConfig',
      ]),
      new \Twig_SimpleFunction('bamboo_state_get', [
        $this,
        'getState',
      ]),
    ];
  }

  /**
   * Unique identifier for this Twig extension.
   */
  public function getName() {
    return 'bamboo_twig_config.twig.config';
  }

  /**
   * Load given Config Settings from the settings.php file.
   *
   * @param string $key
   *   The key of the data to retrieve.
   *
   * @return mixed|null
   *   Returns the stored value for a given key, or NULL if no value exists.
   */
  public function getSettings($key) {
    return $this
      ->getSettingsSingleton()
      ->get($key);
  }

  /**
   * Load given Config API configuration.
   *
   * @param string $key
   *   The key of the data to retrieve.
   * @param string $name
   *   The name of config to retrieve.
   *
   * @return mixed|null
   *   Returns the stored value for a given key, or NULL if no value exists.
   */
  public function getConfig($key, $name) {
    return $this
      ->getConfigFactory()
      ->get($key)
      ->get($name);
  }

  /**
   * Load given State API configuration.
   *
   * @param string $key
   *   The key of the data to retrieve.
   *
   * @return mixed|null
   *   Returns the stored value for a given key, or NULL if no value exists.
   */
  public function getState($key) {
    return $this
      ->getStateFactory()
      ->get($key);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Config::getConfig public function Load given Config API configuration.
Config::getFunctions public function List of all Twig functions.
Config::getName public function Unique identifier for this Twig extension. Overrides TwigExtensionBase::getName
Config::getSettings public function Load given Config Settings from the settings.php file.
Config::getState public function Load given State API configuration.
TwigExtensionBase::getBlockStorage protected function Return the block storage.
TwigExtensionBase::getConfigFactory protected function Provides an interface for a configuration object factory.
TwigExtensionBase::getCurrentRouteMatch protected function Return the current route match.
TwigExtensionBase::getCurrentUser protected function Lazy loading for the Drupal current user account proxy.
TwigExtensionBase::getDateFormatter protected function Provides a service to handle various date related functionality.
TwigExtensionBase::getEntityTypeManager protected function Lazy loading for the Drupal entity type manager.
TwigExtensionBase::getExtensionGuesser protected function Return a singleton mime type to file extension guesser.
TwigExtensionBase::getFieldTypeManager protected function Return the factory for image objects.
TwigExtensionBase::getFileStorage protected function Return the file storage.
TwigExtensionBase::getFileSystemObject protected function Provides helpers to operate on files and stream wrappers.
TwigExtensionBase::getFormBuilder protected function Provides an interface for form building and processing.
TwigExtensionBase::getImageFactory protected function Return the factory for image objects.
TwigExtensionBase::getImageStyleStorage protected function Provides an interface defining an image style.
TwigExtensionBase::getLanguageManager protected function Returns the language manager service.
TwigExtensionBase::getMenuLinkTree protected function Interface for loading, transforming and rendering menu link trees.
TwigExtensionBase::getPluginManagerBlock protected function Manages discovery and instantiation of block plugins.
TwigExtensionBase::getSettingsSingleton protected function Read only settings singleton.
TwigExtensionBase::getStateFactory protected function The state storage service.
TwigExtensionBase::getToken protected function Return the token service.
TwigExtensionBase::getUserStorage protected function Return the user storage.