1 | <?php |
||
20 | class ProcessManager |
||
21 | { |
||
22 | protected $transportFactories = []; |
||
23 | |||
24 | /** |
||
25 | * createDefault creates a Transport manager and add the default transports to it. |
||
26 | */ |
||
27 | public static function createDefault() |
||
36 | |||
37 | /** |
||
38 | * Return a site process configured with an appropriate transport |
||
39 | * |
||
40 | * @param AliasRecord $siteAlias Target for command |
||
41 | * @param array $args Command arguments |
||
42 | * @param array $options Associative array of command options |
||
43 | * @param array $optionsPassedAsArgs Associtive array of options to be passed as arguments (after double-dash) |
||
44 | * @return Process |
||
45 | */ |
||
46 | public function siteProcess(AliasRecord $siteAlias, $args = [], $options = [], $optionsPassedAsArgs = []) |
||
52 | |||
53 | /** |
||
54 | * Create a Process instance from a commandline string. |
||
55 | * @param array $command The command to run and its arguments listed as separate entries |
||
56 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
57 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
58 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
59 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
60 | * @return Process |
||
61 | */ |
||
62 | public function process($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
66 | |||
67 | /** |
||
68 | * Create a Process instance from a commandline string. |
||
69 | * @param string $command The commandline string to run |
||
70 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
71 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
72 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
73 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
74 | * @return Process |
||
75 | */ |
||
76 | public function shell($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
80 | |||
81 | /** |
||
82 | * add a transport factory to our factory list |
||
83 | * @param TransportFactoryInterface $factory |
||
84 | */ |
||
85 | public function add(TransportFactoryInterface $factory) |
||
90 | |||
91 | /** |
||
92 | * hasTransport determines if there is a transport that handles the |
||
93 | * provided site alias. |
||
94 | * |
||
95 | * @param AliasRecord $siteAlias |
||
96 | * @return boolean |
||
97 | */ |
||
98 | public function hasTransport(AliasRecord $siteAlias) |
||
102 | |||
103 | /** |
||
104 | * getTransport returns a transport that is applicable to the provided site alias. |
||
105 | * |
||
106 | * @param AliasRecord $siteAlias |
||
107 | * @return TransportInterface |
||
108 | */ |
||
109 | public function getTransport(AliasRecord $siteAlias) |
||
117 | |||
118 | /** |
||
119 | * getTransportFactory returns a factory for the provided site alias. |
||
120 | * |
||
121 | * @param AliasRecord $siteAlias |
||
122 | * @return TransportFactoryInterface |
||
123 | */ |
||
124 | protected function getTransportFactory(AliasRecord $siteAlias) |
||
133 | } |
||
134 |