You are here

abstract class ListBase in Plugin 8.2

Handles the listing routes.

Hierarchy

Expanded class hierarchy of ListBase

File

src/Controller/ListBase.php, line 14

Namespace

Drupal\plugin\Controller
View source
abstract class ListBase implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs a new class instance.
   *
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The string translator.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   */
  public function __construct(TranslationInterface $string_translation, ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
    $this->stringTranslation = $string_translation;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('string_translation'), $container
      ->get('module_handler'));
  }

  /**
   * Gets the human-readable provider label.
   *
   * @param $provider string
   *
   * @return string
   */
  protected function getProviderLabel($provider) {
    if ($provider == 'core') {
      return $this
        ->t('Core');
    }
    else {
      return $this->moduleHandler
        ->getName($provider);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ListBase::$moduleHandler protected property The module handler.
ListBase::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create 2
ListBase::getProviderLabel protected function Gets the human-readable provider label.
ListBase::__construct public function Constructs a new class instance. 2
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.