1 | <?php |
||
29 | class PhpProcessSpawner |
||
30 | { |
||
31 | /** |
||
32 | * The configuration in use. |
||
33 | * |
||
34 | * @var TensideJsonConfig |
||
35 | */ |
||
36 | private $config; |
||
37 | |||
38 | /** |
||
39 | * The home directory to run the process in. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $homePath; |
||
44 | |||
45 | /** |
||
46 | * Create a new instance. |
||
47 | * |
||
48 | * @param TensideJsonConfig $config The configuration in use. |
||
49 | * |
||
50 | * @param string $homePath The directory to use as home directory. |
||
51 | */ |
||
52 | public function __construct(TensideJsonConfig $config, $homePath) |
||
57 | |||
58 | /** |
||
59 | * Create a new instance. |
||
60 | * |
||
61 | * @param TensideJsonConfig $config The configuration in use. |
||
62 | * |
||
63 | * @param string $homePath The directory to use as home directory. |
||
64 | * |
||
65 | * @return PhpProcessSpawner |
||
66 | */ |
||
67 | public static function create(TensideJsonConfig $config, $homePath) |
||
71 | |||
72 | /** |
||
73 | * Create the process (automatically forcing to background if configured). |
||
74 | * |
||
75 | * @param array $arguments The additional arguments to add to the call. |
||
76 | * |
||
77 | * @return Process |
||
78 | */ |
||
79 | public function spawn(array $arguments) |
||
80 | { |
||
81 | return $this |
||
82 | ->buildInternal($arguments) |
||
83 | ->setForceBackground($this->config->isForceToBackgroundEnabled()) |
||
84 | ->generate(); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Build the internal process builder. |
||
89 | * |
||
90 | * @param array $arguments The arguments. |
||
91 | * |
||
92 | * @return ProcessBuilder |
||
93 | */ |
||
94 | private function buildInternal(array $arguments) |
||
113 | } |
||
114 |