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 | * Return a site process configured with an appropriate transport |
||
55 | * |
||
56 | * @param AliasRecord $siteAlias Target for command |
||
57 | * @param array $args Command arguments |
||
58 | * @param array $options Associative array of command options |
||
59 | * @param array $optionsPassedAsArgs Associtive array of options to be passed as arguments (after double-dash) |
||
60 | * @return Process |
||
61 | */ |
||
62 | public function siteProcess(AliasRecord $siteAlias, $args = [], $options = [], $optionsPassedAsArgs = []) |
||
68 | |||
69 | /** |
||
70 | * Create a Process instance from a commandline string. |
||
71 | * @param array $command The command to run and its arguments listed as separate entries |
||
72 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
73 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
74 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
75 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
76 | * @return Process |
||
77 | */ |
||
78 | public function process($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
82 | |||
83 | /** |
||
84 | * Create a Process instance from a commandline string. |
||
85 | * @param string $command The commandline string to run |
||
86 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP process |
||
87 | * @param array|null $env The environment variables or null to use the same environment as the current PHP process |
||
88 | * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input |
||
89 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
90 | * @return Process |
||
91 | */ |
||
92 | public function shell($command, $cwd = null, array $env = null, $input = null, $timeout = 60) |
||
96 | |||
97 | /** |
||
98 | * add a transport factory to our factory list |
||
99 | * @param TransportFactoryInterface $factory |
||
100 | */ |
||
101 | public function add(TransportFactoryInterface $factory) |
||
106 | |||
107 | /** |
||
108 | * hasTransport determines if there is a transport that handles the |
||
109 | * provided site alias. |
||
110 | * |
||
111 | * @param AliasRecord $siteAlias |
||
112 | * @return boolean |
||
113 | */ |
||
114 | public function hasTransport(AliasRecord $siteAlias) |
||
118 | |||
119 | /** |
||
120 | * getTransport returns a transport that is applicable to the provided site alias. |
||
121 | * |
||
122 | * @param AliasRecord $siteAlias |
||
123 | * @return TransportInterface |
||
124 | */ |
||
125 | public function getTransport(AliasRecord $siteAlias) |
||
133 | |||
134 | /** |
||
135 | * getTransportFactory returns a factory for the provided site alias. |
||
136 | * |
||
137 | * @param AliasRecord $siteAlias |
||
138 | * @return TransportFactoryInterface |
||
139 | */ |
||
140 | protected function getTransportFactory(AliasRecord $siteAlias) |
||
149 | } |
||
150 |