You are here

abstract class SplitCommandBase in Configuration Split 8

Class SplitCommandBase for shared functionality.

@internal

Hierarchy

  • class \Drupal\config_split\Command\SplitCommandBase extends \Drupal\Console\Core\Command\Command

Expanded class hierarchy of SplitCommandBase

File

src/Command/SplitCommandBase.php, line 13

Namespace

Drupal\config_split\Command
View source
abstract class SplitCommandBase extends Command {

  /**
   * The cli service doing all the work.
   *
   * @var \Drupal\config_split\ConfigSplitCliService
   */
  protected $cliService;

  /**
   * Constructor with cli service injection.
   *
   * @param \Drupal\config_split\ConfigSplitCliService $cliService
   *   The cli service to delegate all actions to.
   */
  public function __construct(ConfigSplitCliService $cliService) {
    parent::__construct();
    $this->cliService = $cliService;
  }

  /**
   * The translation function akin to Drupal's t().
   *
   * @param string $string
   *   The string to translate.
   * @param array $args
   *   The replacements.
   *
   * @return string
   *   The translated string.
   */
  public function t($string, array $args = []) {
    $c = 'commands.' . strtr($this
      ->getName(), [
      ':' => '.',
    ]) . '.messages.';
    $translations = [
      'Configuration successfully exported.' => $c . 'success',
    ];
    if (array_key_exists($string, $translations)) {
      $string = $translations[$string];
    }

    // Translate with consoles translations.
    return strtr($this
      ->trans($string), $args);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SplitCommandBase::$cliService protected property The cli service doing all the work.
SplitCommandBase::t public function The translation function akin to Drupal's t().
SplitCommandBase::__construct public function Constructor with cli service injection.