Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 29
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
EmailTemplatesTable
0.00% covered (danger)
0.00%
0 / 29
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 initialize
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 validationDefault
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
2
 buildRules
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare(strict_types=1);
3
4namespace App\Model\Table;
5
6use Cake\ORM\RulesChecker;
7use Cake\ORM\Table;
8use Cake\Validation\Validator;
9
10/**
11 * EmailTemplates Model
12 *
13 * @method \App\Model\Entity\EmailTemplate newEmptyEntity()
14 * @method \App\Model\Entity\EmailTemplate newEntity(array $data, array $options = [])
15 * @method array<\App\Model\Entity\EmailTemplate> newEntities(array $data, array $options = [])
16 * @method \App\Model\Entity\EmailTemplate get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
17 * @method \App\Model\Entity\EmailTemplate findOrCreate($search, ?callable $callback = null, array $options = [])
18 * @method \App\Model\Entity\EmailTemplate patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
19 * @method array<\App\Model\Entity\EmailTemplate> patchEntities(iterable $entities, array $data, array $options = [])
20 * @method \App\Model\Entity\EmailTemplate|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
21 * @method \App\Model\Entity\EmailTemplate saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
22 * @method iterable<\App\Model\Entity\EmailTemplate>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\EmailTemplate>|false saveMany(iterable $entities, array $options = [])
23 * @method iterable<\App\Model\Entity\EmailTemplate>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\EmailTemplate> saveManyOrFail(iterable $entities, array $options = [])
24 * @method iterable<\App\Model\Entity\EmailTemplate>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\EmailTemplate>|false deleteMany(iterable $entities, array $options = [])
25 * @method iterable<\App\Model\Entity\EmailTemplate>|\Cake\Datasource\ResultSetInterface<\App\Model\Entity\EmailTemplate> deleteManyOrFail(iterable $entities, array $options = [])
26 * @mixin \Cake\ORM\Behavior\TimestampBehavior
27 */
28class EmailTemplatesTable extends Table
29{
30    /**
31     * Initialize method
32     *
33     * @param array<string, mixed> $config The configuration for the Table.
34     * @return void
35     */
36    public function initialize(array $config): void
37    {
38        parent::initialize($config);
39
40        $this->setTable('email_templates');
41        $this->setDisplayField('name');
42        $this->setPrimaryKey('id');
43
44        $this->addBehavior('Timestamp');
45    }
46
47    /**
48     * Default validation rules.
49     *
50     * @param \Cake\Validation\Validator $validator Validator instance.
51     * @return \Cake\Validation\Validator
52     */
53    public function validationDefault(Validator $validator): Validator
54    {
55        $validator
56            ->scalar('template_identifier')
57            ->maxLength('template_identifier', 255)
58            ->requirePresence('template_identifier', 'create')
59            ->notEmptyString('template_identifier');
60
61        $validator
62            ->scalar('name')
63            ->maxLength('name', 255)
64            ->requirePresence('name', 'create')
65            ->notEmptyString('name');
66
67        $validator
68            ->scalar('subject')
69            ->maxLength('subject', 255)
70            ->requirePresence('subject', 'create')
71            ->notEmptyString('subject');
72
73        $validator
74            ->scalar('body_html')
75            ->allowEmptyString('body_html');
76
77        $validator
78            ->scalar('body_plain')
79            ->allowEmptyString('body_plain');
80
81        return $validator;
82    }
83
84    /**
85     * Returns a rules checker object that will be used for validating
86     * application integrity.
87     *
88     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
89     * @return \Cake\ORM\RulesChecker
90     */
91    public function buildRules(RulesChecker $rules): RulesChecker
92    {
93        $rules->add($rules->isUnique(['id']), ['errorField' => 'id']);
94
95        return $rules;
96    }
97}