You are here

class TwigExtensionBase in Bamboo Twig 8.5

Same name and namespace in other branches
  1. 8.2 src/TwigExtension/TwigExtensionBase.php \Drupal\bamboo_twig\TwigExtension\TwigExtensionBase
  2. 8.3 src/TwigExtension/TwigExtensionBase.php \Drupal\bamboo_twig\TwigExtension\TwigExtensionBase
  3. 8.4 src/TwigExtension/TwigExtensionBase.php \Drupal\bamboo_twig\TwigExtension\TwigExtensionBase

Provides a Twig Extension Lazy Service Injection.

Hierarchy

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

Expanded class hierarchy of TwigExtensionBase

7 files declare their use of TwigExtensionBase
Config.php in bamboo_twig_config/src/TwigExtension/Config.php
File.php in bamboo_twig_file/src/TwigExtension/File.php
I18n.php in bamboo_twig_i18n/src/TwigExtension/I18n.php
Loader.php in bamboo_twig_loader/src/TwigExtension/Loader.php
Render.php in bamboo_twig_loader/src/TwigExtension/Render.php

... See full list

1 string reference to 'TwigExtensionBase'
bamboo_twig.services.yml in ./bamboo_twig.services.yml
bamboo_twig.services.yml
1 service uses TwigExtensionBase
bamboo_twig.twig.base in ./bamboo_twig.services.yml
Drupal\bamboo_twig\TwigExtension\TwigExtensionBase

File

src/TwigExtension/TwigExtensionBase.php, line 11

Namespace

Drupal\bamboo_twig\TwigExtension
View source
class TwigExtensionBase extends \Twig_Extension {
  use ContainerAwareTrait;

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

  /**
   * Lazy loading for the Drupal entity type manager.
   *
   * @return \Drupal\Core\Entity\EntityTypeManagerInterface
   *   Return the Drupal entity type manager.
   */
  protected function getEntityTypeManager() {
    return $this->container
      ->get('entity_type.manager');
  }

  /**
   * Lazy loading for the Drupal entity repository.
   *
   * @return \Drupal\Core\Entity\EntityRepositoryInterface
   *   Return the Drupal entity repository.
   */
  protected function getEntityRepository() {
    return $this->container
      ->get('entity.repository');
  }

  /**
   * Return the current route match.
   *
   * @return \Drupal\Core\Routing\RouteMatchInterface
   *   Return the current route match.
   */
  protected function getCurrentRouteMatch() {
    return $this->container
      ->get('current_route_match');
  }

  /**
   * Manages discovery and instantiation of block plugins.
   *
   * @return \Drupal\Core\Block\BlockManagerInterface
   *   Return the block manager.
   */
  protected function getPluginManagerBlock() {
    return $this->container
      ->get('plugin.manager.block');
  }

  /**
   * Provides an interface for form building and processing.
   *
   * @return \Drupal\Core\Form\FormBuilderInterface
   *   Return the interface for form building and processing.
   */
  protected function getFormBuilder() {
    return $this->container
      ->get('form_builder');
  }

  /**
   * Interface for loading, transforming and rendering menu link trees.
   *
   * @return \Drupal\Core\Menu\MenuLinkTreeInterface
   *   Return the interface for loading, transforming and rendering menu link.
   */
  protected function getMenuLinkTree() {
    return $this->container
      ->get('menu.link_tree');
  }

  /**
   * Read only settings singleton.
   *
   * @return \Drupal\Core\Site\Settings
   *   Return The settings object.
   */
  protected function getSettingsSingleton() {
    return $this->container
      ->get('settings');
  }

  /**
   * Provides an interface for a configuration object factory.
   *
   * @return \Drupal\Core\Config\ConfigFactoryInterface
   *   Return the interface for a configuration object factory.
   */
  protected function getConfigFactory() {
    return $this->container
      ->get('config.factory');
  }

  /**
   * The state storage service.
   *
   * @return \\Drupal\Core\State\StateInterface
   *   Return the state storage service.
   */
  protected function getStateFactory() {
    return $this->container
      ->get('state');
  }

  /**
   * Lazy loading for the Drupal current user account proxy.
   *
   * @return \Drupal\Core\Session\AccountInterface
   *   Return The current user account proxy.
   */
  protected function getCurrentUser() {
    return $this->container
      ->get('current_user');
  }

  /**
   * Return the user storage.
   *
   * @return \Drupal\user\UserStorageInterface
   *   Return the user storage.
   */
  protected function getUserStorage() {
    return $this
      ->getEntityTypeManager()
      ->getStorage('user');
  }

  /**
   * Return the block storage.
   *
   * @return \Drupal\user\UserStorageInterface
   *   Return the block storage.
   */
  protected function getBlockStorage() {
    return $this
      ->getEntityTypeManager()
      ->getStorage('block');
  }

  /**
   * Return the file storage.
   *
   * @return \Drupal\Component\PhpStorage\FileStorage
   *   Return the file storage.
   */
  protected function getFileStorage() {
    return $this
      ->getEntityTypeManager()
      ->getStorage('file');
  }

  /**
   * Provides an interface defining an image style.
   *
   * @return \Drupal\image\ImageStyleInterface
   *   Return interface for image style.
   */
  protected function getImageStyleStorage() {
    return $this
      ->getEntityTypeManager()
      ->getStorage('image_style');
  }

  /**
   * Return the factory for image objects.
   *
   * @return \Drupal\Core\Image\ImageFactory
   *   Return the factory for image objects.
   */
  protected function getImageFactory() {
    return $this->container
      ->get('image.factory');
  }

  /**
   * Return the factory for image objects.
   *
   * @return \Drupal\Core\Field\FieldTypePluginManager
   *   Return the factory for image objects.
   */
  protected function getFieldTypeManager() {
    return $this->container
      ->get('plugin.manager.field.field_type');
  }

  /**
   * Return the token service.
   *
   * @return \Drupal\Core\Utility\Token
   *   Return the token service.
   */
  protected function getToken() {
    return $this->container
      ->get('token');
  }

  /**
   * Return a singleton mime type to file extension guesser.
   *
   * @return \Symfony\Component\Mime\MimeTypesInterface
   *   Return a MIME type object for MIME type guessing.
   */
  protected function getExtensionGuesser() {
    return new MimeTypes();
  }

  /**
   * Provides a service to handle various date related functionality.
   *
   * @return \Drupal\Core\Datetime\DateFormatterInterface
   *   The Date Formatter service.
   */
  protected function getDateFormatter() {
    return $this->container
      ->get('date.formatter');
  }

  /**
   * Returns the language manager service.
   *
   * @return \Drupal\Core\Language\LanguageManagerInterface
   *   The Language Manager service.
   */
  protected function getLanguageManager() {
    return $this->container
      ->get('language_manager');
  }

  /**
   * Provides helpers to operate on files and stream wrappers.
   *
   * @return \Drupal\Core\File\FileSystemInterface
   *   Return the File System object.
   */
  protected function getFileSystemObject() {
    return $this->container
      ->get('file_system');
  }

  /**
   * Provides a StreamWrapper manager.
   *
   * @return \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
   *   The stream wrapper manager service.
   */
  protected function getStreamWrapperManager() {
    return $this->container
      ->get('stream_wrapper_manager');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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::getEntityRepository protected function Lazy loading for the Drupal entity repository.
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::getName public function Unique identifier for this Twig extension. 7
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::getStreamWrapperManager protected function Provides a StreamWrapper manager.
TwigExtensionBase::getToken protected function Return the token service.
TwigExtensionBase::getUserStorage protected function Return the user storage.