/
SelectValueOptionList.php
59 lines (51 loc) · 1.34 KB
/
SelectValueOptionList.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
<?php
namespace Concrete\Core\Entity\Attribute\Value\Value;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="atSelectOptionLists")
*/
class SelectValueOptionList
{
/**
* @ORM\Id @ORM\Column(type="integer", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $avSelectOptionListID;
/**
* @ORM\OneToMany(targetEntity="SelectValueOption", mappedBy="list", cascade={"all"})
* @ORM\JoinColumn(name="avSelectOptionListID", referencedColumnName="avSelectOptionListID")
*/
protected $options;
/**
* SelectValueOptionList constructor.
*
* @param $options
*/
public function __construct()
{
$this->options = new ArrayCollection();
}
/**
* @return mixed
*/
public function getOptions()
{
return $this->options;
}
/**
* @param mixed $options
*/
public function setOptions($options)
{
$this->options = $options;
}
public function contains(SelectValueOption $option)
{
$id = $option->getSelectAttributeOptionID();
return count(array_filter($this->getOptions()->toArray(), function ($option) use ($id) {
return $option->getSelectAttributeOptionID() == $id;
})) > 0;
}
}