forked from Svaroh/JsFormValidatorBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUniqueEntity.php
More file actions
executable file
·46 lines (40 loc) · 1.04 KB
/
Copy pathUniqueEntity.php
File metadata and controls
executable file
·46 lines (40 loc) · 1.04 KB
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
<?php
namespace Fp\JsFormValidatorBundle\Form\Constraint;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity as BaseUniqueEntity;
/**
* Class UniqueEntity
* @package Fp\JsFormValidatorBundle\Form\Constraint
*/
class UniqueEntity extends BaseUniqueEntity
{
/**
* @var string
*/
public $entityName = null;
/**
* @var int|string|null
*/
public $entityId = null;
/**
* @var mixed
*/
protected $entity = null;
/**
* @param BaseUniqueEntity $base
* @param string $entityName
* @param mixed $entity
*/
public function __construct(BaseUniqueEntity $base, $entityName, $entity = null)
{
foreach (get_object_vars($base) as $prop => $value) {
$this->{$prop} = $value;
}
$this->entityName = $entityName;
if (is_object($entity)) {
$this->entity = $entity;
if (method_exists($entity, 'getId')) {
$this->entityId = $entity->getId();
}
}
}
}