forked from AppStateESS/InternshipInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkflowTransition.php
97 lines (78 loc) · 2.23 KB
/
WorkflowTransition.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Intern;
abstract class WorkflowTransition {
const sourceState = ''; // Name of Source/Dest states
const destState = '';
const actionName = '';
const sortIndex = 5;
protected $source;
public function __construct(){
}
abstract function getAllowedPermissionList();
/**
* Determines if this transition is applicable to the given Internship. If not,
* the transition will not be shown in the list of actions for the user.
* NB: This is distinct from the allowed() method because a return value of false
* from allowed() will show the action as a disabled (grey'd out) in the list of
* actions.
*
* Returns true by default, unless overridden by a child class.
*
* @param Internship $i
* @return boolean
*/
public function isApplicable(Internship $i){
return true; // Returns true by default
}
public function allowed(Internship $i)
{
$perms = $this->getAllowedPermissionList();
foreach($perms as $p){
if(\Current_User::allow('intern', $p)){
return true;
}
}
return false;
}
public function setSourceState(WorkflowState $state)
{
$this->source = $state;
}
public function onTransition(Internship $i)
{
// Do nothing by default.
}
public function doNotification(Internship $i, $note = null)
{
// Do nothing by default. Send notifications here.
}
public function checkRequiredFields(Internship $i)
{
// Do nothing by default.
// Check for required data here before allowing internship to complete this transition.
}
public function getName()
{
return get_called_class();
}
public function getActionName()
{
$class = get_called_class();
return $class::actionName;
}
public function getSourceState()
{
$class = get_called_class();
return $class::sourceState;
}
public function getDestState()
{
$class = get_called_class();
return $class::destState;
}
public function getSortIndex()
{
$class = get_called_class();
return $class::sortIndex;
}
}