1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* |
5
|
|
|
* @filesource |
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
7
|
|
|
* @license MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
/** StatusInterface.php */ |
11
|
|
|
|
12
|
|
|
namespace Jobs\Entity; |
13
|
|
|
|
14
|
|
|
use Core\Entity\EntityTrait; |
15
|
|
|
use Core\Entity\Status\AbstractSortableStatus; |
16
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Job status entity |
20
|
|
|
* |
21
|
|
|
* @ODM\EmbeddedDocument |
22
|
|
|
*/ |
23
|
|
|
class Status extends AbstractSortableStatus implements StatusInterface |
24
|
|
|
{ |
25
|
|
|
use EntityTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* status values |
29
|
|
|
*/ |
30
|
|
|
protected static $sortMap = array( |
31
|
|
|
self::CREATED => 10, |
32
|
|
|
self::WAITING_FOR_APPROVAL => 20, |
33
|
|
|
self::REJECTED => 30, |
34
|
|
|
self::PUBLISH => 40, |
35
|
|
|
self::ACTIVE => 50, |
36
|
|
|
self::INACTIVE => 60, |
37
|
|
|
self::EXPIRED => 70, |
38
|
|
|
); |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* name of the job status |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
* @ODM\Field(type="string") |
45
|
|
|
* @deprecated since 0.29, replaced by AbstractStatus::$state |
46
|
|
|
*/ |
47
|
|
|
protected $name; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* integer for ordering states. |
51
|
|
|
* |
52
|
|
|
* @var int |
53
|
|
|
* @ODM\Field(type="int") |
54
|
|
|
* @deprecated since 0.29, replaced by AbstractSortableStatus::$sort |
55
|
|
|
*/ |
56
|
|
|
protected $order; |
57
|
|
|
|
58
|
10 |
|
public function __construct($status = self::CREATED) |
59
|
|
|
{ |
60
|
10 |
|
parent::__construct($status); |
61
|
|
|
|
62
|
10 |
|
$constant = 'self::' . strtoupper(str_replace(' ', '_', $status)); |
63
|
10 |
|
if (!defined($constant)) { |
64
|
|
|
throw new \DomainException('Unknown status: ' . $status); |
65
|
|
|
} |
66
|
10 |
|
$this->name=constant($constant); |
|
|
|
|
67
|
10 |
|
$this->order=$this->getOrder(); |
|
|
|
|
68
|
10 |
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @see \Jobs\Entity\StatusInterface::getName() |
72
|
|
|
* @return String |
73
|
|
|
* @deprecated since 0,29, use __toString() |
74
|
|
|
*/ |
75
|
|
|
public function getName() |
76
|
|
|
{ |
77
|
|
|
return isset($this->name)?$this->name:''; |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @see \Jobs\Entity\StatusInterface::getOrder() |
82
|
|
|
* @return Int |
83
|
|
|
* @deprecated since 0,29, no replacement. |
84
|
|
|
*/ |
85
|
|
|
public function getOrder() |
86
|
|
|
{ |
87
|
|
|
return self::$sortMap[$this->getName()]; |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @todo remove this some versions after 0.29 |
92
|
|
|
* |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
1 |
|
public function __toString() |
96
|
|
|
{ |
97
|
1 |
|
if (!$this->state) { |
98
|
|
|
$this->state = $this->name; |
|
|
|
|
99
|
|
|
} |
100
|
1 |
|
return parent::__toString(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @todo remove this some versions after 0.29 |
105
|
|
|
* |
106
|
|
|
* @param object|string $state |
107
|
|
|
* |
108
|
|
|
* @return bool |
109
|
|
|
*/ |
110
|
|
|
public function is($state) |
111
|
|
|
{ |
112
|
|
|
if (!$this->state) { |
113
|
|
|
$this->state = $this->name; |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
return parent::is($state); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.