1 | <?php |
||
25 | class ProcessManager implements ConfigAwareInterface |
||
26 | { |
||
27 | use ConfigAwareTrait; |
||
28 | |||
29 | /** @var ConfigInterface */ |
||
30 | protected $configRuntime; |
||
31 | |||
32 | protected $transportFactories = []; |
||
33 | |||
34 | public function __construct() |
||
39 | |||
40 | /** |
||
41 | * setConfigRuntime sets the config object that holds runtime config |
||
42 | * items, i.e. config set from the commandline rather than a config file. |
||
43 | * Configuration priority (highest to lowest) is: |
||
44 | * - config runtime |
||
45 | * - site alias |
||
46 | * - config files |
||
47 | */ |
||
48 | public function setConfigRuntime(ConfigInterface $configRuntime) |
||
53 | |||
54 | /** |
||
55 | * createDefault creates a Transport manager and add the default transports to it. |
||
56 | */ |
||
57 | public static function createDefault() |
||
62 | |||
63 | /** |
||
64 | * addTransports adds the avaiable transports to the |
||
65 | * provided process manager. |
||
66 | */ |
||
67 | public static function addTransports(ProcessManager $processManager) |
||
74 | |||
75 | /** |
||
76 | * Return a site process configured with an appropriate transport |
||
77 | * |
||
78 | * @param SiteAliasInterface $siteAlias Target for command |
||
79 | * @param array $args Command arguments |
||
80 | * @param array $options Associative array of command options |
||
81 | * @param array $optionsPassedAsArgs Associtive array of options to be passed as arguments (after double-dash) |
||
82 | * @return Process |
||
83 | */ |
||
84 | public function siteProcess(SiteAliasInterface $siteAlias, $args = [], $options = [], $optionsPassedAsArgs = []) |
||
90 | |||
91 | /** |
||
92 | * Create a Process instance from a commandline string. |
||
93 | * @param array $command The command to run and its arguments listed as separate entries |
||
94 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
95 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
96 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
97 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
98 | * @return Process |
||
99 | */ |
||
100 | public function process($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
104 | |||
105 | /** |
||
106 | * Create a Process instance from a commandline string. |
||
107 | * @param string $command The commandline string to run |
||
108 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
109 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
110 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
111 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
112 | * @return Process |
||
113 | */ |
||
114 | public function shell($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
118 | |||
119 | /** |
||
120 | * add a transport factory to our factory list |
||
121 | * @param TransportFactoryInterface $factory |
||
122 | */ |
||
123 | public function add(TransportFactoryInterface $factory) |
||
128 | |||
129 | /** |
||
130 | * hasTransport determines if there is a transport that handles the |
||
131 | * provided site alias. |
||
132 | * |
||
133 | * @param SiteAliasInterface $siteAlias |
||
134 | * @return boolean |
||
135 | */ |
||
136 | public function hasTransport(SiteAliasInterface $siteAlias) |
||
140 | |||
141 | /** |
||
142 | * getTransport returns a transport that is applicable to the provided site alias. |
||
143 | * |
||
144 | * @param SiteAliasInterface $siteAlias |
||
145 | * @return TransportInterface |
||
146 | */ |
||
147 | public function getTransport(SiteAliasInterface $siteAlias) |
||
158 | |||
159 | /** |
||
160 | * getTransportFactory returns a factory for the provided site alias. |
||
161 | * |
||
162 | * @param SiteAliasInterface $siteAlias |
||
163 | * @return TransportFactoryInterface |
||
164 | */ |
||
165 | protected function getTransportFactory(SiteAliasInterface $siteAlias) |
||
174 | } |
||
175 |