-
Notifications
You must be signed in to change notification settings - Fork 2
/
EntityException.php
executable file
·60 lines (51 loc) · 1.69 KB
/
EntityException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Webiny Framework (http://www.webiny.com/framework)
*
* @copyright Copyright Webiny LTD
*/
namespace Webiny\Component\Entity;
use Webiny\Component\StdLib\Exception\AbstractException;
use Webiny\Component\StdLib\StdObject\StdObjectWrapper;
/**
* Exception class for the Entity component.
*
* @package Webiny\Component\Entity
*/
class EntityException extends AbstractException
{
const VALIDATION_FAILED = 101;
const ENTITY_DELETION_RESTRICTED = 102;
const NO_MATCHING_MANY2MANY_ATTRIBUTE_FOUND = 103;
const ATTRIBUTE_NOT_FOUND = 104;
const INVALID_MANY2MANY_VALUE = 105;
const INVALID_ONE2MANY_VALUE = 106;
protected $invalidAttributes = [];
protected static $messages = [
101 => "Validation of '%s' failed with '%s' errors.",
102 => "Entity is linked with other entities via '%s' attribute and can not be deleted.",
103 => "No matching Many2Many attribute was found between entities '%s' and '%s' for attribute '%s'.",
104 => "AttributeType '%s' was not found in '%s' entity.",
105 => "Many2Many attribute '%s' expects '%s', instance of '%s' given.",
106 => "One2Many attribute '%s' expects an instance of '%s', instance of '%s' given.",
];
public function setInvalidAttributes($attributes)
{
$this->invalidAttributes = StdObjectWrapper::toArray($attributes);
return $this;
}
/**
* Get array of invalid attributes and validation exceptions
* Array structure:
*
* <code>
* ['attrName' => ValidationException]
* </code>
*
* @return array
*/
public function getInvalidAttributes()
{
return $this->invalidAttributes;
}
}