|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the official Pagantis module for PrestaShop. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pagantis <[email protected]> |
|
6
|
|
|
* @copyright 2019 Pagantis |
|
7
|
|
|
* @license proprietary |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
use Pagantis\ModuleUtils\Model\Log\LogEntry; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class AbstractController |
|
14
|
|
|
*/ |
|
15
|
|
|
abstract class AbstractController extends ModuleFrontController |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* CODE |
|
19
|
|
|
*/ |
|
20
|
|
|
const CODE = 'pagantis'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var array $headers |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $headers; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Configure redirection |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $url |
|
31
|
|
|
* @param array $parameters |
|
32
|
|
|
*/ |
|
33
|
|
|
public function redirect($url = '', $parameters = array()) |
|
34
|
|
|
{ |
|
35
|
|
|
$parsedUrl = parse_url($url); |
|
36
|
|
|
$separator = ($parsedUrl['query'] == null) ? '?' : '&'; |
|
37
|
|
|
$redirectUrl = $url. $separator . http_build_query($parameters); |
|
38
|
|
|
Tools::redirect($redirectUrl); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Save log in SQL database |
|
43
|
|
|
* |
|
44
|
|
|
* @param array $data |
|
45
|
|
|
* @param \Exception $exception |
|
46
|
|
|
*/ |
|
47
|
|
|
public function saveLog($data = array(), $exception = null) |
|
48
|
|
|
{ |
|
49
|
|
|
$response = ""; |
|
50
|
|
|
try { |
|
51
|
|
|
if (count($data) > 0) { |
|
52
|
|
|
$response = json_encode($data); |
|
53
|
|
|
} elseif (!is_null($exception)) { |
|
54
|
|
|
$logEntry = new LogEntry(); |
|
55
|
|
|
$logEntry->error($exception); |
|
56
|
|
|
$response = $logEntry->toJson(); |
|
57
|
|
|
} |
|
58
|
|
|
if (is_null($response)) { |
|
|
|
|
|
|
59
|
|
|
if (!is_null($exception)) { |
|
60
|
|
|
$response = $exception->getMessage(); |
|
61
|
|
|
} else { |
|
62
|
|
|
$response = 'Unable to serialize log.'. |
|
63
|
|
|
'data: '. json_encode($data). |
|
64
|
|
|
'exception: '. json_encode($exception); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
Db::getInstance()->insert('pagantis_log', array( |
|
|
|
|
|
|
69
|
|
|
'log' => str_replace("'", "\'", $response) |
|
70
|
|
|
)); |
|
71
|
|
|
} catch (\Exception $error) { |
|
72
|
|
|
// Do nothing |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths