| 1 | <?php |
||
| 2 | |||
| 3 | // ------------------------------------------------------------------------- |
||
| 4 | // OVIDENTIA http://www.ovidentia.org |
||
| 5 | // Ovidentia is free software; you can redistribute it and/or modify |
||
| 6 | // it under the terms of the GNU General Public License as published by |
||
| 7 | // the Free Software Foundation; either version 2, or (at your option) |
||
| 8 | // any later version. |
||
| 9 | // |
||
| 10 | // This program is distributed in the hope that it will be useful, but |
||
| 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | // See the GNU General Public License for more details. |
||
| 14 | // |
||
| 15 | // You should have received a copy of the GNU General Public License |
||
| 16 | // along with this program; if not, write to the Free Software |
||
| 17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
||
| 18 | // USA. |
||
| 19 | // ------------------------------------------------------------------------- |
||
| 20 | /** |
||
| 21 | * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
||
| 22 | * @copyright Copyright (c) 2022 by SI4YOU ({@link https://www.siforyou.com}) |
||
| 23 | */ |
||
| 24 | namespace Capwelton\LibApp\Set; |
||
| 25 | |||
| 26 | use bab_charset; |
||
| 27 | use Capwelton\LibOrm\MySql\ORMMySqlIterator; |
||
|
0 ignored issues
–
show
|
|||
| 28 | |||
| 29 | /** |
||
| 30 | * @property string $name |
||
| 31 | * @property string $description |
||
| 32 | * @property string $object |
||
| 33 | * @property string $view |
||
| 34 | * @property string $fields |
||
| 35 | * @property string $classname |
||
| 36 | * @property string $sizePolicy |
||
| 37 | * @property string $layout |
||
| 38 | * @property int $rank |
||
| 39 | * @property string $visibilityCriteria |
||
| 40 | * |
||
| 41 | * @method Func_App App() |
||
| 42 | */ |
||
| 43 | class AppCustomContainer extends AppTraceableRecord |
||
| 44 | { |
||
| 45 | |||
| 46 | const LAYOUT_VERTICAL_BOX = 'vbox'; |
||
| 47 | |||
| 48 | const LAYOUT_HORIZONTAL_BOX = 'hbox'; |
||
| 49 | |||
| 50 | const LAYOUT_FLOW = 'flow'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string[] |
||
| 54 | */ |
||
| 55 | public static function getLayouts() |
||
| 56 | { |
||
| 57 | static $layouts = null; |
||
| 58 | |||
| 59 | if(! isset($layouts)){ |
||
| 60 | $layouts = array( |
||
| 61 | self::LAYOUT_VERTICAL_BOX => app_translate('Vertical box'), |
||
| 62 | self::LAYOUT_HORIZONTAL_BOX => app_translate('Horizontal box'), |
||
| 63 | self::LAYOUT_FLOW => app_translate('Flow box') |
||
| 64 | ); |
||
| 65 | } |
||
| 66 | return $layouts; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @param AppRecord $record |
||
| 71 | * |
||
| 72 | * @return bool |
||
| 73 | */ |
||
| 74 | public function isVisibleForRecord(AppRecord $record) |
||
| 75 | { |
||
| 76 | if(empty($this->visibilityCriteria)){ |
||
| 77 | return true; |
||
| 78 | } |
||
| 79 | |||
| 80 | $App = \bab_functionality::get('App'); |
||
| 81 | $recordSet = $record->getParentSet(); |
||
| 82 | |||
| 83 | $arrCriteria = json_decode($this->visibilityCriteria, true); |
||
| 84 | if(bab_charset::getIso() != bab_charset::UTF_8){ |
||
| 85 | $arrCriteria = app_utf8Encode($arrCriteria); |
||
| 86 | } |
||
| 87 | foreach ($arrCriteria as $fieldName => $condition){ |
||
| 88 | if(strpos($fieldName, '/') !== false){ |
||
| 89 | list ($oneField, $foreignField) = explode('/', $fieldName); |
||
| 90 | $field = $recordSet->$oneField()->$foreignField; |
||
| 91 | } |
||
| 92 | else{ |
||
| 93 | $field = $recordSet->$fieldName; |
||
| 94 | } |
||
| 95 | foreach ($condition as $op => $value){ |
||
| 96 | if(! is_array($value)){ |
||
| 97 | $criteria = $field->$op($value); |
||
| 98 | } |
||
| 99 | else{ |
||
| 100 | foreach ($value as $foreignClassName => $foreignValues){ |
||
| 101 | $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
||
| 102 | $foreignSet = $App->$foreignClassName(); |
||
| 103 | $foreignField = ''; |
||
| 104 | $foreignCondition = ''; |
||
| 105 | foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
||
| 106 | if($foreignFieldName === '_foreignField'){ |
||
| 107 | $foreignField = $foreignConditions; |
||
| 108 | } |
||
| 109 | else{ |
||
| 110 | foreach ($foreignConditions as $key => $val){ |
||
| 111 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
||
| 112 | } |
||
| 113 | } |
||
| 114 | } |
||
| 115 | } |
||
| 116 | if(method_exists($foreignSet, 'getDefaultCriteria')){ |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 117 | $foreignCondition = $foreignCondition->_AND_($foreignSet->getDefaultCriteria()); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 118 | } |
||
| 119 | $criteria = $field->in($foreignCondition, $foreignField); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 120 | } |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 124 | $criteria = $criteria->_AND_($recordSet->id->is($record->id)); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 125 | |||
| 126 | /** |
||
| 127 | * @var ORMMySqlIterator |
||
| 128 | */ |
||
| 129 | $records = $recordSet->select($criteria); |
||
| 130 | |||
| 131 | return ($records->count() != 0); |
||
| 132 | } |
||
| 133 | } |
||
| 134 |
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