1 | <?php |
||
30 | abstract class AbstractDevice |
||
31 | { |
||
32 | /** |
||
33 | * Use command line options |
||
34 | */ |
||
35 | use CommandLineParametersTrait; |
||
36 | |||
37 | /** |
||
38 | * Use rendering parameters |
||
39 | */ |
||
40 | use RenderingTrait; |
||
41 | |||
42 | /** |
||
43 | * Use page parameters |
||
44 | */ |
||
45 | use PageTrait; |
||
46 | |||
47 | /** |
||
48 | * Use font-related parameters |
||
49 | */ |
||
50 | use FontTrait; |
||
51 | |||
52 | /** |
||
53 | * Use resource-related parameters |
||
54 | */ |
||
55 | use ResourceTrait; |
||
56 | |||
57 | /** |
||
58 | * Use interaction parameters |
||
59 | */ |
||
60 | use InteractionTrait; |
||
61 | |||
62 | /** |
||
63 | * Use device and output selection parameters |
||
64 | */ |
||
65 | use OutputSelectionTrait; |
||
66 | |||
67 | /** |
||
68 | * Use EPS parameters |
||
69 | */ |
||
70 | use EpsTrait; |
||
71 | |||
72 | /** |
||
73 | * Use ICC color parameters |
||
74 | */ |
||
75 | use IccColorTrait; |
||
76 | |||
77 | /** |
||
78 | * Use other parameters |
||
79 | */ |
||
80 | use OtherTrait; |
||
81 | |||
82 | /** |
||
83 | * PostScript commands to be executed via command line when using this device. |
||
84 | */ |
||
85 | const POSTSCRIPT_COMMANDS = ''; |
||
86 | |||
87 | /** |
||
88 | * The Ghostscript object |
||
89 | * |
||
90 | * @var Ghostscript |
||
91 | */ |
||
92 | protected $ghostscript; |
||
93 | |||
94 | /** |
||
95 | * The arguments object |
||
96 | * |
||
97 | * @var Arguments |
||
98 | */ |
||
99 | private $arguments; |
||
100 | |||
101 | /** |
||
102 | * List of input files |
||
103 | * |
||
104 | * @var array |
||
105 | */ |
||
106 | private $inputFiles = []; |
||
107 | |||
108 | /** |
||
109 | * Whether to read input from stdin |
||
110 | * |
||
111 | * @var bool |
||
112 | */ |
||
113 | private $inputStdin = false; |
||
114 | |||
115 | /** |
||
116 | * Create abstract device object |
||
117 | * |
||
118 | * @param Ghostscript $ghostscript |
||
119 | * @param Arguments $arguments |
||
120 | */ |
||
121 | 30 | public function __construct(Ghostscript $ghostscript, Arguments $arguments) |
|
126 | |||
127 | /** |
||
128 | * Get Argument |
||
129 | * |
||
130 | * @param string $name |
||
131 | * |
||
132 | * @return null|Argument |
||
133 | */ |
||
134 | 6 | protected function getArgument($name) |
|
138 | |||
139 | /** |
||
140 | * Whether argument is set |
||
141 | * |
||
142 | * @param string $name |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | 2 | protected function hasArgument($name) |
|
150 | |||
151 | /** |
||
152 | * Get argument value |
||
153 | * |
||
154 | * @param string $name |
||
155 | * |
||
156 | * @return null|string |
||
157 | */ |
||
158 | 2 | protected function getArgumentValue($name) |
|
167 | |||
168 | /** |
||
169 | * Set argument |
||
170 | * |
||
171 | * @param string $argument |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | 6 | protected function setArgument($argument) |
|
181 | |||
182 | /** |
||
183 | * Set a generic command line parameter with a string value |
||
184 | * |
||
185 | * @param string $param the parameter name |
||
186 | * @param string $value the parameter value |
||
187 | * |
||
188 | * @return $this |
||
189 | */ |
||
190 | 2 | public function setStringParameter($param, $value) |
|
196 | |||
197 | /** |
||
198 | * Set a generic command line parameter with a token value |
||
199 | * |
||
200 | * @param string $param the parameter name |
||
201 | * @param mixed $value the parameter value |
||
202 | * |
||
203 | * @return $this |
||
204 | */ |
||
205 | 2 | public function setTokenParameter($param, $value) |
|
211 | |||
212 | /** |
||
213 | * Add an input file |
||
214 | * |
||
215 | * @param string $inputFile a path to an existing file |
||
216 | * |
||
217 | * @throws \RuntimeException if $inputFile does not exist |
||
218 | * |
||
219 | * @return $this |
||
220 | */ |
||
221 | 14 | public function addInputFile($inputFile) |
|
230 | |||
231 | /** |
||
232 | * Add an stdin as input file |
||
233 | * |
||
234 | * @return $this |
||
235 | */ |
||
236 | 8 | public function addInputStdin() |
|
242 | |||
243 | /** |
||
244 | * Create process object |
||
245 | * |
||
246 | * @param string $inputFile either a path to an existing file or a dash (-) to read input from stdin |
||
247 | * |
||
248 | * @throws \RuntimeException if $inputFile does not exist |
||
249 | * |
||
250 | * @return Process |
||
251 | */ |
||
252 | 16 | public function createProcess($inputFile = null) |
|
277 | |||
278 | /** |
||
279 | * Reset the input-related fields of this device. |
||
280 | * Future processes created from this device will have their own input parameters. |
||
281 | */ |
||
282 | 14 | private function resetInput() |
|
287 | } |
||
288 |