|
@@ -0,0 +1,35 @@
|
|
1
|
+<?php
|
|
2
|
+/**
|
|
3
|
+ * Created by PhpStorm.
|
|
4
|
+ * User: robin
|
|
5
|
+ * Date: 11/24/15
|
|
6
|
+ * Time: 5:17 PM
|
|
7
|
+ */
|
|
8
|
+
|
|
9
|
+namespace App\Http\Business\Commands;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+class PiFaceCommand extends AbstractCommand
|
|
13
|
+{
|
|
14
|
+
|
|
15
|
+ /**
|
|
16
|
+ * @return bool
|
|
17
|
+ */
|
|
18
|
+ public function exec()
|
|
19
|
+ {
|
|
20
|
+ $data = $this->_command->getData();
|
|
21
|
+ $args = [
|
|
22
|
+ 'camotion-pifaceo'
|
|
23
|
+ ];
|
|
24
|
+ foreach ($data["Commands"] as $cmd) {
|
|
25
|
+ $args[] = escapeshellarg("--" . $cmd);
|
|
26
|
+ }
|
|
27
|
+ $cli = implode(' ', $args);
|
|
28
|
+ $code = 0;
|
|
29
|
+ $output = [];
|
|
30
|
+ exec($cli, $output, $code);
|
|
31
|
+ if ($code != 0) {
|
|
32
|
+ abort(500, "PiFace failed with code " . $code);
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+}
|