/
option.php
79 lines (67 loc) · 2.16 KB
/
option.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Concrete\Attribute\Select;
use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption;
use Gettext\Translations;
/**
* @deprecated use methods in Concrete\Attribute\Select\Controller instead
*/
class Option
{
/**
* @param Key $ak
* @param $option
* @param int $isEndUserAdded
* @return Option
* @deprecated use Concrete\Attribute\Select\Controller::setOptions()
*/
public static function add($ak, $value, $isEndUserAdded = 0)
{
/**
* @var $type SelectSettings
*/
$type = $ak->getAttributeKeySettings();
$list = $type->getOptionList();
$option = new SelectValueOption();
$option->setSelectAttributeOptionValue($value);
$option->setIsEndUserAdded($isEndUserAdded);
$option->setOptionList($list);
$em = \Database::connection()->getEntityManager();
$em->persist($option);
$em->flush();
return $option;
}
/**
* @deprecated use Concrete\Attribute\Select\Controller::getOptionByID()
*/
public static function getByID($id)
{
$em = \Database::connection()->getEntityManager();
return $em->find('\Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption', $id);
}
/**
* @deprecated use Concrete\Attribute\Select\Controller::getOptionByValue()
*/
public static function getByValue($value, $ak = false)
{
$em = \Database::connection()->getEntityManager();
$controller = new \Concrete\Attribute\Select\Controller($em);
return $controller->getOptionByValue($value, $ak);
}
/**
* @deprecated
*/
public static function exportTranslations()
{
$translations = new Translations();
$em = \Database::connection()->getEntityManager();
$options = $em->getRepository(SelectValueOption::class)->findAll();
/**
* @var $option SelectValueOption
*/
foreach($options as $option) {
$translations->insert('SelectAttributeValue', $option->getSelectAttributeOptionValue());
}
return $translations;
}
}