1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Zemit Framework. |
4
|
|
|
* |
5
|
|
|
* (c) Zemit Team <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE.txt |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Zemit\Models; |
12
|
|
|
|
13
|
|
|
use Zemit\Models\Abstracts\AbstractRoleFeature; |
14
|
|
|
use Zemit\Models\Interfaces\RoleFeatureInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @property Role $RoleEntity |
18
|
|
|
* @method Role getRoleEntity(?array $params = null) |
19
|
|
|
* |
20
|
|
|
* @property Feature $FeatureEntity |
21
|
|
|
* @method Feature getFeatureEntity(?array $params = null) |
22
|
|
|
*/ |
23
|
|
|
class RoleFeature extends AbstractRoleFeature implements RoleFeatureInterface |
24
|
|
|
{ |
25
|
|
|
protected $deleted = self::NO; |
26
|
|
|
protected $position = self::NO; |
27
|
|
|
|
28
|
|
|
public function initialize(): void |
29
|
|
|
{ |
30
|
|
|
parent::initialize(); |
31
|
|
|
|
32
|
|
|
$this->hasOne('roleId', Role::class, 'id', ['alias' => 'Role']); |
33
|
|
|
$this->hasOne('featureId', Feature::class, 'id', ['alias' => 'Feature']); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function validation(): bool |
37
|
|
|
{ |
38
|
|
|
$validator = $this->genericValidation(); |
39
|
|
|
|
40
|
|
|
$this->addUniquenessValidation($validator, ['roleId', 'featureId']); |
41
|
|
|
$this->addUnsignedIntValidation($validator, 'roleId', false); |
42
|
|
|
$this->addUnsignedIntValidation($validator, 'featureId', false); |
43
|
|
|
|
44
|
|
|
return $this->validate($validator); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|