|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Canvas\CustomFields; |
|
5
|
|
|
|
|
6
|
|
|
use Canvas\Models\CustomFieldsModules; |
|
7
|
|
|
use Canvas\Models\AbstractModel; |
|
8
|
|
|
use Baka\Database\Contracts\CustomFields\CustomFieldsTrait; |
|
|
|
|
|
|
9
|
|
|
use PDO; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Custom Fields Abstract Class. |
|
13
|
|
|
* @property \Phalcon\Di $di |
|
14
|
|
|
*/ |
|
15
|
|
|
abstract class AbstractCustomFieldsModel extends AbstractModel |
|
16
|
|
|
{ |
|
17
|
|
|
use CustomFieldsTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Get all custom fields of the given object. |
|
21
|
|
|
* |
|
22
|
|
|
* @param array $fields |
|
23
|
|
|
* @return array |
|
24
|
|
|
*/ |
|
25
|
|
|
public function getAllCustomFields(array $fields = []) |
|
26
|
|
|
{ |
|
27
|
|
|
//no di? ok so no custom fields |
|
28
|
|
|
if (!$this->di->has('userData')) { |
|
29
|
|
|
return ; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
//We does it only find names in plural? We need to fix this or make a workaroun |
|
33
|
|
|
if (!$models = CustomFieldsModules::findFirstByName($this->getSource())) { |
|
34
|
|
|
return; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$bind = [$this->getId(), $this->di->getApp()->getId(), $models->getId(), $this->di->getUserData()->currentCompanyId()]; |
|
38
|
|
|
|
|
39
|
|
|
// $customFieldsValueTable = $this->getSource() . '_custom_fields'; |
|
40
|
|
|
$customFieldsValueTable = $this->getSource() . '_custom_fields'; |
|
41
|
|
|
|
|
42
|
|
|
//We are to make a new query to replace old Canvas implementation. |
|
43
|
|
|
$result = $this->getReadConnection()->prepare("SELECT l.{$this->getSource()}_id, |
|
44
|
|
|
c.id as field_id, |
|
45
|
|
|
c.name, |
|
46
|
|
|
l.value , |
|
47
|
|
|
c.users_id, |
|
48
|
|
|
l.created_at, |
|
49
|
|
|
l.updated_at |
|
50
|
|
|
FROM {$customFieldsValueTable} l, |
|
51
|
|
|
custom_fields c |
|
52
|
|
|
WHERE c.id = l.custom_fields_id |
|
53
|
|
|
AND l.{$this->getSource()}_id = ? |
|
54
|
|
|
AND c.apps_id = ? |
|
55
|
|
|
AND c.custom_fields_modules_id = ? |
|
56
|
|
|
AND c.companies_id = ? "); |
|
57
|
|
|
|
|
58
|
|
|
$result->execute($bind); |
|
59
|
|
|
|
|
60
|
|
|
$listOfCustomFields = []; |
|
61
|
|
|
|
|
62
|
|
|
while ($row = $result->fetch(PDO::FETCH_OBJ)) { |
|
63
|
|
|
$listOfCustomFields[$row->name] = $row->value; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return $listOfCustomFields; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Before create. |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public function beforeCreate() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->created_at = date('Y-m-d H:i:s'); |
|
|
|
|
|
|
77
|
|
|
$this->updated_at = null; |
|
|
|
|
|
|
78
|
|
|
$this->is_deleted = 0; |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
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