ChangelogsTable::validationDefault()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 1
1
<?php
2
namespace Changelog\Model\Table;
3
4
use Cake\ORM\Query;
5
use Cake\ORM\RulesChecker;
6
use Cake\ORM\Table;
7
use Cake\Validation\Validator;
8
9
/**
10
 * Changelogs Model
11
 *
12
 * @property \Cake\ORM\Association\HasMany $ChangelogColumns
13
 *
14
 * @method \Changelog\Model\Entity\Changelog get($primaryKey, $options = [])
15
 * @method \Changelog\Model\Entity\Changelog newEntity($data = null, array $options = [])
16
 * @method \Changelog\Model\Entity\Changelog[] newEntities(array $data, array $options = [])
17
 * @method \Changelog\Model\Entity\Changelog|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
18
 * @method \Changelog\Model\Entity\Changelog patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
19
 * @method \Changelog\Model\Entity\Changelog[] patchEntities($entities, array $data, array $options = [])
20
 * @method \Changelog\Model\Entity\Changelog findOrCreate($search, callable $callback = null, $options = [])
21
 *
22
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
23
 */
24
class ChangelogsTable extends Table
25
{
26
27
    /**
28
     * Initialize method
29
     *
30
     * @param array $config The configuration for the Table.
31
     * @return void
32
     */
33
    public function initialize(array $config)
34
    {
35
        parent::initialize($config);
36
37
        $this->table('changelogs');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\Table::table() has been deprecated with message: 3.4.0 Use setTable()/getTable() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
38
        $this->displayField('id');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\Table::displayField() has been deprecated with message: 3.4.0 Use setDisplayField()/getDisplayField() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
39
        $this->primaryKey('id');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\Table::primaryKey() has been deprecated with message: 3.4.0 Use setPrimaryKey()/getPrimaryKey() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
40
41
        $this->addBehavior('Timestamp');
42
43
        $this->hasMany('ChangelogColumns', [
44
            'foreignKey' => 'changelog_id',
45
            'className' => 'Changelog.ChangelogColumns'
46
        ]);
47
    }
48
49
    /**
50
     * Default validation rules.
51
     *
52
     * @param \Cake\Validation\Validator $validator Validator instance.
53
     * @return \Cake\Validation\Validator
54
     */
55
    public function validationDefault(Validator $validator)
56
    {
57
        $validator
58
            ->integer('id')
59
            ->allowEmpty('id', 'create');
60
61
        $validator
62
            ->requirePresence('model', 'create')
63
            ->notEmpty('model');
64
65
        $validator
66
            ->requirePresence('foreign_key', 'create')
67
            ->notEmpty('foreign_key');
68
69
        $validator
70
            ->boolean('is_new')
71
            ->requirePresence('is_new', 'create')
72
            ->notEmpty('is_new');
73
74
        return $validator;
75
    }
76
77
}
78