You are here

protected function ExecutableFinderTrait::findExecutable in Tome 8

Finds an executable string for the current process.

Parameters

\Symfony\Component\Console\Input\InputInterface $input: The command input.

Return value

string An executable string, i.e. "drush @foo.bar" or "./vendor/bin/drupal".

1 call to ExecutableFinderTrait::findExecutable()
CommandBase::initialize in modules/tome_base/src/CommandBase.php

File

modules/tome_base/src/ExecutableFinderTrait.php, line 23

Class

ExecutableFinderTrait
Contains methods useful for finding the current executable.

Namespace

Drupal\tome_base

Code

protected function findExecutable(InputInterface $input) {
  $args = [];
  foreach ($_SERVER['argv'] as $arg) {
    if ($arg === $input
      ->getFirstArgument()) {
      break;
    }
    if (strpos($arg, '--backend') !== 0) {
      $args[] = $arg;
    }
  }
  if (isset($_SERVER['PWD']) && !is_file($args[0]) && is_file($_SERVER['PWD'] . '/' . $args[0])) {
    $args[0] = $_SERVER['PWD'] . '/' . $args[0];
  }
  return implode(' ', $args);
}