Программно выполнить Drush команды

Пример программного вызова Drush команд:

<?php

namespace Drupal\example\Commands;

use Consolidation\SiteAlias\SiteAliasManagerAwareInterface;
use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
use Drush\Drush;

/**
 * Drush command to install and configure website using "minimal" profile.
 */
class ExampeCommands extends DrushCommands implements SiteAliasManagerAwareInterface {

  use SiteAliasManagerAwareTrait;

  /**
   * Install and configure Drupal.
   *
   * @command example:site:install
   *
   * @aliases example:si
   */
  public function install() {
    $this->siteInstall()
      ->cacheClear()
      ->localeCheck()
      ->localeUpdate()
      ->cacheClear();
  }

  /**
   * Installs Drupal using "minimal" profile and exported configurations.
   *
   * @return $this
   *   Self object.
   */
  protected function siteInstall(): self {
    $this->runCommand('si', ['minimal'], [
      'existing-config' => NULL,
    ]);

    return $this;
  }

  /**
   * Clears all Drupal caches.
   *
   * @return $this
   *   Self object.
   */
  protected function cacheClear(): self {
    $this->runCommand('cr');

    return $this;
  }

  /**
   * Checks for available translation updates.
   *
   * @return $this
   *   Self object.
   */
  protected function localeCheck(): self {
    $this->runCommand('locale-check');

    return $this;
  }

  /**
   * Imports the available translation updates.
   *
   * @return $this
   *   Self object.
   */
  protected function localeUpdate(): self {
    $this->runCommand('locale-update');

    return $this;
  }

  /**
   * Runs drush command.
   *
   * @param string $command
   *   Command to run.
   * @param array $args
   *   Arguments of command.
   * @param array $options
   *   Options of command.
   */
  protected function runCommand(string $command, array $args = [], array $options = []) {
    $process = Drush::drush(
      $this->siteAliasManager()->getSelf(),
      $command,
      $args,
      $options
    );

    $process->mustrun($process->showRealtime());
  }

}
Benya