ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilWorkflowScaffold.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 #region Requires / File inclusion
15
17 public $requires = array();
18
21
24
27
30
34 public function registerRequire($require)
35 {
36 if(!in_array($require, $this->requires))
37 {
38 $this->requires[] = $require;
39 }
40 }
41
45 public function getRequires()
46 {
47 $requires = '';
48 foreach($this->requires as $required_file)
49 {
50 $requires .= "require_once '" . $required_file . "';\n";
51 }
52 return $requires;
53 }
54
55 #endregion
56
57 #region StartEvent Message Registration and Handling
58
61
65 public function registerStartEventRef($start_event_ref)
66 {
67 $this->start_event_refs[] = array('type' => 'message', 'ref' => $start_event_ref);
68 }
69
73 public function registerStartSignalRef($start_event_ref)
74 {
75 $this->start_event_refs[] = array('type' => 'signal', 'ref' => $start_event_ref);
76 }
77
81 public function registerStartTimerRef($start_event_ref)
82 {
83 $this->start_event_refs[] = array('type' => 'timeDate', 'ref' => $start_event_ref);
84 }
85
89 public function getStartEventInfo()
90 {
91 $event_definitions = array();
92 foreach((array)$this->start_event_refs as $start_event_ref)
93 {
94 $event_definition = array();
95 switch($start_event_ref['type'])
96 {
97 case 'message':
99 $start_event_ref['ref'],
100 'message',
101 $this->bpmn2_array
102 );
103 break;
104 case 'signal':
106 $start_event_ref['ref'],
107 'signal',
108 $this->bpmn2_array
109 );
110 break;
111 case 'timeDate':
112 $event_definition = $this->getTimeDateEventDefinition($start_event_ref['ref']);
113 break;
114 }
115 $event_definitions[] = $event_definition;
116 }
117
118 if(count($event_definitions))
119 {
120 $code = '
121 public static $startEventRequired = true;
122 '."
123 public static function getStartEventInfo()
124 {";
125 foreach ($event_definitions as $event_definition)
126 {
127 $code .= '
128 $events[] = ' . "array(
129 'type' => '".$event_definition['type'] ."',
130 'content' => '".$event_definition['content'] ."',
131 'subject_type' => '".$event_definition['subject_type'] ."',
132 'subject_id' => '".$event_definition['subject_id'] ."',
133 'context_type' => '".$event_definition['context_type'] ."',
134 'context_id' => '".$event_definition['context_id'] ."',
135 );
136 ";
137 }
138 $code .= '
139 return $events;
140 }
141 ';
142 return $code;
143 }
144 else
145 {
146 return '
147 public static $startEventRequired = false;
148 ';
149 }
150 }
151
152 #endregion
153
158 {
159 $this->workflow_name = $workflow_name;
160 }
161
165 public function addAuxilliaryMethod($auxilliary_method)
166 {
167 $this->auxilliary_methods[] = $auxilliary_method;
168 }
169
170 public function __construct($bpmn2_array)
171 {
172 $this->registerRequire('./Services/WorkflowEngine/classes/workflows/class.ilBaseWorkflow.php');
173 $this->bpmn2_array = $bpmn2_array;
174 $this->auxilliary_methods = array();
175 }
176
181 {
183 }
184
189 {
190 $this->constructor_method_content = $constructor_method_content;
191 }
192
196 public function getPHP()
197 {
198 $pre_constructor_content = $this->getRequires();
199 $pre_constructor_content .= "
200 class " . $this->workflow_name . " extends ilBaseWorkflow
201 {
202 " . $this->getStartEventInfo() . "
203 public function __construct()
204 {
205 ";
206
207 $post_constructor_content = "
208 }";
209 foreach($this->auxilliary_methods as $auxilliary_method)
210 {
211 $post_constructor_content .= "
212
213 " . $auxilliary_method . "
214 ";
215 }
216 $post_constructor_content .= "
217 }
218 ";
219
220 return $pre_constructor_content . $this->constructor_method_content . $post_constructor_content;
221 }
222
228 public function getTimeDateEventDefinition($start_event_ref)
229 {
230 $content = '';
231 foreach((array)$this->bpmn2_array['children'] as $elements)
232 {
233 foreach((array)$elements['children'] as $element)
234 {
235 if ($element['name'] == 'startEvent' && @$element['children'][0]['name'] == 'timerEventDefinition')
236 {
237 $timer_element = $element['children'][0];
238 $content = $timer_element['children'][0]['content'];
239 }
240 }
241 }
242
243 $start = date('U',strtotime($content));
244 $end = 0;
245
246 return array(
247 'type' => 'time_passed',
248 'content' => 'time_passed',
249 'subject_type' => 'none',
250 'subject_id' => 0,
251 'context_type' => 'none',
252 'context_id' => 0,
253 'listening_start' => $start,
254 'listening_end' => $end
255 );
256 }
257}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
static extractILIASEventDefinitionFromProcess($start_event_ref, $type, $bpmn2_array)
Class ilWorkflowScaffold.
registerStartEventRef($start_event_ref)
addAuxilliaryMethod($auxilliary_method)
registerStartSignalRef($start_event_ref)
setConstructorMethodContent($constructor_method_content)
getTimeDateEventDefinition($start_event_ref)
registerStartTimerRef($start_event_ref)
$code
Definition: example_050.php:99