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