1 | <?php |
||
22 | class ProcessManager |
||
23 | { |
||
24 | protected $transportFactories = []; |
||
25 | protected $config; |
||
26 | |||
27 | public function __construct() |
||
31 | |||
32 | /** |
||
33 | * createDefault creates a Transport manager and add the default transports to it. |
||
34 | */ |
||
35 | public static function createDefault() |
||
44 | |||
45 | /** |
||
46 | * Set a reference to the config object. |
||
47 | */ |
||
48 | public function setConfig(ConfigInterface $config) |
||
52 | |||
53 | /** |
||
54 | * Get a reference to the config object |
||
55 | */ |
||
56 | protected function getConfig() |
||
60 | |||
61 | /** |
||
62 | * Return a site process configured with an appropriate transport |
||
63 | * |
||
64 | * @param AliasRecord $siteAlias Target for command |
||
65 | * @param array $args Command arguments |
||
66 | * @param array $options Associative array of command options |
||
67 | * @param array $optionsPassedAsArgs Associtive array of options to be passed as arguments (after double-dash) |
||
68 | * @return Process |
||
69 | */ |
||
70 | public function siteProcess(AliasRecord $siteAlias, $args = [], $options = [], $optionsPassedAsArgs = []) |
||
76 | |||
77 | /** |
||
78 | * Create a Process instance from a commandline string. |
||
79 | * @param array $command The command to run and its arguments listed as separate entries |
||
80 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
81 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
82 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
83 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
84 | * @return Process |
||
85 | */ |
||
86 | public function process($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
90 | |||
91 | /** |
||
92 | * Create a Process instance from a commandline string. |
||
93 | * @param string $command The commandline string to run |
||
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 shell($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
104 | |||
105 | /** |
||
106 | * add a transport factory to our factory list |
||
107 | * @param TransportFactoryInterface $factory |
||
108 | */ |
||
109 | public function add(TransportFactoryInterface $factory) |
||
114 | |||
115 | /** |
||
116 | * hasTransport determines if there is a transport that handles the |
||
117 | * provided site alias. |
||
118 | * |
||
119 | * @param AliasRecord $siteAlias |
||
120 | * @return boolean |
||
121 | */ |
||
122 | public function hasTransport(AliasRecord $siteAlias) |
||
126 | |||
127 | /** |
||
128 | * getTransport returns a transport that is applicable to the provided site alias. |
||
129 | * |
||
130 | * @param AliasRecord $siteAlias |
||
131 | * @return TransportInterface |
||
132 | */ |
||
133 | public function getTransport(AliasRecord $siteAlias) |
||
141 | |||
142 | /** |
||
143 | * getTransportFactory returns a factory for the provided site alias. |
||
144 | * |
||
145 | * @param AliasRecord $siteAlias |
||
146 | * @return TransportFactoryInterface |
||
147 | */ |
||
148 | protected function getTransportFactory(AliasRecord $siteAlias) |
||
157 | } |
||
158 |