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'); |
|
|
|
|
38
|
|
|
$this->displayField('id'); |
|
|
|
|
39
|
|
|
$this->primaryKey('id'); |
|
|
|
|
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
|
|
|
|
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.