bakaphp /
phalcon-api
| 1 | <?php |
||||||
| 2 | declare(strict_types=1); |
||||||
| 3 | |||||||
| 4 | namespace Gewaer\CustomFields; |
||||||
| 5 | |||||||
| 6 | use Gewaer\Models\Modules; |
||||||
| 7 | |||||||
| 8 | abstract class AbstractCustomFieldsModel extends \Baka\Database\ModelCustomFields |
||||||
| 9 | { |
||||||
| 10 | /** |
||||||
| 11 | * Get all custom fields of the given object |
||||||
| 12 | * |
||||||
| 13 | * @param array $fields |
||||||
| 14 | * @return \Phalcon\Mvc\Model |
||||||
| 15 | */ |
||||||
| 16 | 4 | public function getAllCustomFields(array $fields = [], int $company_id = 0) |
|||||
|
0 ignored issues
–
show
|
|||||||
| 17 | { |
||||||
| 18 | //We does it only find names in plural? We need to fix this or make a workaroun |
||||||
| 19 | 4 | if (!$models = Modules::findFirstByName($this->getSource())) { |
|||||
|
0 ignored issues
–
show
The method
findFirstByName() does not exist on Gewaer\Models\Modules. Since you implemented __callStatic, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 20 | return; |
||||||
| 21 | } |
||||||
| 22 | |||||||
| 23 | 4 | $conditions = []; |
|||||
|
0 ignored issues
–
show
|
|||||||
| 24 | 4 | $fieldsIn = null; |
|||||
| 25 | |||||||
| 26 | 4 | if (!empty($fields)) { |
|||||
| 27 | $fieldsIn = " and name in ('" . implode("','", $fields) . ')'; |
||||||
| 28 | } |
||||||
| 29 | |||||||
| 30 | 4 | $conditions = 'modules_id = ? ' . $fieldsIn; |
|||||
| 31 | |||||||
| 32 | 4 | $bind = [$this->getId(), $this->di->getApp()->getId(), $models->getId(), $this->di->getUserData()->default_company]; |
|||||
|
0 ignored issues
–
show
The property
di does not exist on Gewaer\CustomFields\AbstractCustomFieldsModel. Since you implemented __get, consider adding a @property annotation.
Loading history...
The method
getApp() does not exist on Phalcon\Mvc\Model\Resultset.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
The method
getUserData() does not exist on Phalcon\Mvc\Model\Resultset.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 33 | |||||||
| 34 | // $customFieldsValueTable = $this->getSource() . '_custom_fields'; |
||||||
| 35 | 4 | $customFieldsValueTable = $this->getSource() . '_custom_fields'; |
|||||
| 36 | |||||||
| 37 | //We are to make a new query to replace old gewaer implementation. |
||||||
| 38 | 4 | $result = $this->getReadConnection()->prepare("SELECT l.{$this->getSource()}_id, |
|||||
|
1 ignored issue
–
show
The method
prepare() does not exist on Phalcon\Db\AdapterInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Phalcon\Db\Adapter. Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 39 | c.id as field_id, |
||||||
| 40 | c.name, |
||||||
| 41 | l.value , |
||||||
| 42 | c.users_id, |
||||||
| 43 | l.created_at, |
||||||
| 44 | l.updated_at |
||||||
| 45 | 4 | FROM {$customFieldsValueTable} l, |
|||||
| 46 | custom_fields c |
||||||
| 47 | WHERE c.id = l.custom_fields_id |
||||||
| 48 | 4 | AND l.{$this->getSource()}_id = ? |
|||||
| 49 | AND c.apps_id = ? |
||||||
| 50 | AND c.modules_id = ? |
||||||
| 51 | AND c.companies_id = ? |
||||||
| 52 | AND l.companies_id = c.companies_id"); |
||||||
| 53 | |||||||
| 54 | 4 | $result->execute($bind); |
|||||
| 55 | |||||||
| 56 | // $listOfCustomFields = $result->fetchAll(); |
||||||
| 57 | 4 | $listOfCustomFields = []; |
|||||
| 58 | |||||||
| 59 | 4 | while ($row = $result->fetch(\PDO::FETCH_OBJ)) { |
|||||
| 60 | $listOfCustomFields[$row->name] = $row->value; |
||||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | 4 | return $listOfCustomFields; |
|||||
|
0 ignored issues
–
show
|
|||||||
| 64 | } |
||||||
| 65 | |||||||
| 66 | /** |
||||||
| 67 | * Get all custom fields of the given model |
||||||
| 68 | * |
||||||
| 69 | * @param array $fields |
||||||
| 70 | * @return \Phalcon\Mvc\Model |
||||||
| 71 | */ |
||||||
| 72 | public function getCustomFieldsByModel($modelName) |
||||||
| 73 | { |
||||||
| 74 | if (!$module = Modules::findFirstByName($modelName)) { |
||||||
| 75 | return; |
||||||
| 76 | } |
||||||
| 77 | $allFields = []; |
||||||
| 78 | if ($fields = \Incursio\Models\CustomFields::findByModulesId($module->id)->toArray()) { |
||||||
|
0 ignored issues
–
show
The type
Incursio\Models\CustomFields was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 79 | foreach ($fields as $field) { |
||||||
| 80 | array_push($allFields, $field['name']); |
||||||
| 81 | } |
||||||
| 82 | return $allFields; |
||||||
| 83 | } |
||||||
| 84 | } |
||||||
| 85 | } |
||||||
| 86 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.