Issues (538)

programs/Set/AppLogSet.php (9 issues)

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 Capwelton\LibApp\Func_App;
27
use Capwelton\LibOrm\Criteria\ORMCriteria;
0 ignored issues
show
The type Capwelton\LibOrm\Criteria\ORMCriteria 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use Capwelton\LibOrm\ORMRecordSet;
0 ignored issues
show
The type Capwelton\LibOrm\ORMRecordSet 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
30
use function Capwelton\LibOrm\ORM_StringField;
0 ignored issues
show
The function Capwelton\LibOrm\ORM_StringField was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
use function Capwelton\LibOrm\ORM_IntField;
0 ignored issues
show
The function Capwelton\LibOrm\ORM_IntField was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
32
use function Capwelton\LibOrm\ORM_DatetimeField;
0 ignored issues
show
The function Capwelton\LibOrm\ORM_DatetimeField was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
use function Capwelton\LibOrm\ORM_UserField;
0 ignored issues
show
The function Capwelton\LibOrm\ORM_UserField was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
use function Capwelton\LibOrm\ORM_BoolField;
0 ignored issues
show
The function Capwelton\LibOrm\ORM_BoolField was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
use function Capwelton\LibOrm\ORM_TextField;
0 ignored issues
show
The function Capwelton\LibOrm\ORM_TextField was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
36
37
/**
38
 * @property ORM_StringField $objectClass
39
 * @property ORM_IntField $objectId
40
 * @property ORM_DateTimeField $modifiedOn
41
 * @property ORM_UserField $modifiedBy
42
 * @property ORM_BoolField $noTrace
43
 * @property ORM_TextField $data
44
 *
45
 * @method app_Log get()
46
 * @method app_Log request()
47
 * @method app_Log[]|\ORM_Iterator select()
48
 * @method app_Log newRecord()
49
 * @method Func_App App()
50
 */
51
class AppLogSet extends AppRecordSet
52
{
53
    
54
    public function __construct(Func_App $App)
55
    {
56
        parent::__construct($App);
57
        
58
        $this->setPrimaryKey('id');
59
        
60
        $this->addFields(
61
            ORM_StringField('objectClass')->setDescription('Created by'), 
62
            ORM_IntField('objectId')->setDescription('Modified by'), 
63
            ORM_DatetimeField('modifiedOn')->setDescription('Modified on'), 
64
            ORM_UserField('modifiedBy')->setDescription('Modified by'), 
65
            ORM_BoolField('noTrace')->setDescription('Not traced'), 
66
            ORM_TextField('data')->setDescription('Serialized object data')
67
        );
68
    }
69
    
70
    /**
71
     * Serialize of AppRecord in order to store it in the log.
72
     *
73
     * @return array
74
     */
75
    public function serialize(AppRecord $record)
76
    {
77
        $values = $record->getValues();
78
        foreach ($values as $key => $value){
79
            if($value instanceof ORMRecordSet){
80
                $values[$key] = $value->id;
81
            }
82
        }
83
        
84
        return serialize($values);
0 ignored issues
show
Bug Best Practice introduced by
The expression return serialize($values) returns the type string which is incompatible with the documented return type array.
Loading history...
85
    }
86
    
87
    /**
88
     * Match log records for the specified AppRecord.
89
     *
90
     * @param AppRecord $record
91
     * @return ORMCriteria
92
     */
93
    public function hasObject(AppRecord $record)
94
    {
95
        return $this->objectClass->is(get_class($record))->_AND_($this->objectId->is($record->id));
96
    }
97
}
98
99
/**
100
 * @property string $objectClass
101
 * @property int $objectId
102
 * @property string $modifiedOn
103
 * @property int $modifiedBy
104
 * @property bool $noTrace
105
 * @property string $data
106
 *
107
 * @method AppLogSet getParent()
108
 * @method Func_App App()
109
 */
110
class AppLog extends AppRecord
111
{
112
}
113