Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Common / ProcessExecutor.php
1 <?php
2
3 namespace Robo\Common;
4
5 use Psr\Log\LoggerAwareInterface;
6 use Robo\Contract\ConfigAwareInterface;
7 use Robo\Contract\OutputAwareInterface;
8 use Robo\Contract\VerbosityThresholdInterface;
9 use Symfony\Component\Process\Process;
10
11 class ProcessExecutor implements ConfigAwareInterface, LoggerAwareInterface, OutputAwareInterface, VerbosityThresholdInterface
12 {
13     use ExecTrait;
14     use TaskIO; // uses LoggerAwareTrait and ConfigAwareTrait
15     use ProgressIndicatorAwareTrait;
16     use OutputAwareTrait;
17
18     /**
19      * @param Process $process
20      * @return type
21      */
22     public function __construct(Process $process)
23     {
24         $this->process = $process;
25     }
26
27     public static function create($container, $process)
28     {
29         $processExecutor = new self($process);
30
31         $processExecutor->setLogger($container->get('logger'));
32         $processExecutor->setProgressIndicator($container->get('progressIndicator'));
33         $processExecutor->setConfig($container->get('config'));
34         $processExecutor->setOutputAdapter($container->get('outputAdapter'));
35
36         return $processExecutor;
37     }
38
39     /**
40      * @return string
41      */
42     protected function getCommandDescription()
43     {
44         return $this->process->getCommandLine();
45     }
46
47     public function run()
48     {
49         return $this->execute($this->process);
50     }
51 }