ChangelogColumnsTable::initialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
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
 * ChangelogColumns Model
11
 *
12
 * @property \Cake\ORM\Association\BelongsTo $Changelogs
13
 *
14
 * @method \Changelog\Model\Entity\ChangelogColumn get($primaryKey, $options = [])
15
 * @method \Changelog\Model\Entity\ChangelogColumn newEntity($data = null, array $options = [])
16
 * @method \Changelog\Model\Entity\ChangelogColumn[] newEntities(array $data, array $options = [])
17
 * @method \Changelog\Model\Entity\ChangelogColumn|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
18
 * @method \Changelog\Model\Entity\ChangelogColumn patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
19
 * @method \Changelog\Model\Entity\ChangelogColumn[] patchEntities($entities, array $data, array $options = [])
20
 * @method \Changelog\Model\Entity\ChangelogColumn findOrCreate($search, callable $callback = null, $options = [])
21
 *
22
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
23
 */
24
class ChangelogColumnsTable 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('changelog_columns');
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->belongsTo('Changelogs', [
44
            'foreignKey' => 'changelog_id',
45
            'joinType' => 'INNER',
46
            'className' => 'Changelog.Changelogs'
47
        ]);
48
    }
49
50
    /**
51
     * Default validation rules.
52
     *
53
     * @param \Cake\Validation\Validator $validator Validator instance.
54
     * @return \Cake\Validation\Validator
55
     */
56
    public function validationDefault(Validator $validator)
57
    {
58
        $validator
59
            ->integer('id')
60
            ->allowEmpty('id', 'create');
61
62
        $validator
63
            ->requirePresence('column', 'create')
64
            ->notEmpty('column');
65
66
        $validator
67
            ->allowEmpty('before');
68
69
        $validator
70
            ->allowEmpty('after');
71
72
        return $validator;
73
    }
74
75
    /**
76
     * Returns a rules checker object that will be used for validating
77
     * application integrity.
78
     *
79
     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
80
     * @return \Cake\ORM\RulesChecker
81
     */
82
    public function buildRules(RulesChecker $rules)
83
    {
84
        $rules->add($rules->existsIn(['changelog_id'], 'Changelogs'));
85
86
        return $rules;
87
    }
88
}
89