-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
process.php
71 lines (59 loc) · 1.55 KB
/
process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Process
*
* Copyright (c) 2020 biati digital
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*
* @author biati digital <https://www.biati.digital>
* @version 2.0.1
* @create date 12-11-2019
* @modify date 06-09-2020
*/
if (getenv('alfred_debug')) {
error_reporting(E_ALL);
error_reporting(-1);
ini_set('error_reporting', E_ALL);
}
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/alfred/Alfred.php';
require_once __DIR__ . '/workflow/calculateanything.php';
use function Alfred\cleanQuery;
$query = cleanQuery($query);
$action = isset($action) ? $action : '';
$calculate = new Workflow\CalculateAnything($query);
$processed = [];
$alfred = ['items' => []];
switch ($action) {
case 'vat':
$processed = $calculate->processVat();
break;
case 'time':
$processed = $calculate->processTime();
break;
case 'color':
$processed = $calculate->processColor();
break;
default:
$processed = $calculate->processQuery();
}
if (!empty($processed['rerun'])) {
$alfred['rerun'] = $processed['rerun'];
unset($processed['rerun']);
if (!isset($processed['variables'])) {
$processed['variables'] = [];
}
$processed['variables']['rerun'] = true;
}
if (isset($processed['variables'])) {
$alfred['variables'] = $processed['variables'];
unset($processed['variables']);
}
if ($processed) {
$alfred['items'] = $processed;
echo json_encode($alfred);
exit(0);
}
echo json_encode($alfred);
exit(0);