ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilStaticMethodCallActivity.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 require_once './Services/WorkflowEngine/interfaces/ilActivity.php';
7 require_once './Services/WorkflowEngine/interfaces/ilNode.php';
8 
21 {
23  private $context;
24 
26  private $include_file = '';
27 
34  private $class_and_method_name = '';
35 
37  private $parameters;
38 
40  private $outputs;
41 
43  protected $name;
44 
50  public function __construct(ilNode $context)
51  {
52  $this->context = $context;
53  }
54 
64  public function setIncludeFilename($filename)
65  {
66  $this->include_file = $filename;
67  }
68 
74  public function getIncludeFilename()
75  {
76  return $this->include_file;
77  }
78 
79  /***
80  * Sets the class- and methodname of the method to be called.
81  * E.g. ilPonyStable::getPony
82  *
83  * @see $method_name
84  *
85  * @param string $name Classname::Methodname.
86  *
87  * @return void
88  */
89  public function setClassAndMethodName($name)
90  {
91  $this->class_and_method_name = $name;
92  }
93 
99  public function getClassAndMethodName()
100  {
102  }
103 
112  public function setParameters($params)
113  {
114  $this->parameters = $params;
115  }
116 
122  public function getParameters()
123  {
124  return $this->parameters;
125  }
126 
130  public function getOutputs()
131  {
132  return $this->outputs;
133  }
134 
138  public function setOutputs($outputs)
139  {
140  $this->outputs = $outputs;
141  }
142 
150  public function execute()
151  {
153  require_once './' . $this->include_file;
154  $name = explode('::', $this->class_and_method_name);
155 
156  $list = (array)$this->context->getContext()->getInstanceVars();
157  $params = array();
158  foreach($this->parameters as $key => $parameter)
159  {
160  $set = false;
161  foreach($list as $instance_var)
162  {
163  if($instance_var['id'] == $parameter)
164  {
165  $set = true;
166  $role = $instance_var['role'];
167  if($instance_var['reference'] == true)
168  {
169  foreach($list as $definitions)
170  {
171  if($definitions['id'] == $instance_var['target'])
172  {
173  $role = $definitions['role'];
174  }
175  }
176  }
177  $params[$role] = $this->context->getContext()->getInstanceVarById($parameter);
178  }
179  }
180  if(!$set)
181  {
182  $params[$parameter] = $parameter;
183  $params[$key] = $parameter;
184  }
185  }
186 
188  $return_value = call_user_func_array(
189  array($name[0], $name[1]),
190  array($this, array($params, $this->outputs))
191  );
192  foreach((array) $return_value as $key => $value)
193  {
194  $this->context->getContext()->setInstanceVarById($key, $value);
195  }
196  }
197 
203  public function getContext()
204  {
205  return $this->context;
206  }
207 
211  public function setName($name)
212  {
213  $this->name = $name;
214  }
215 
219  public function getName()
220  {
221  return $this->name;
222  }
223 }
ilWorkflowEngineElement Interface is part of the petri net based workflow engine. ...
getClassAndMethodName()
Returns the currently set class- and methodname of the method to be called.
__construct(ilNode $context)
Default constructor.
getIncludeFilename()
Returns the currently set filename of the classfile to be included.
getParameters()
Returns the currently set parameters to be passed to the method.
PhpIncludeInspection
Definition: ilNode.php:25
Create styles array
The data for the language used.
setParameters($params)
Sets an array with params for the method.
ilActivity Interface is part of the petri net based workflow engine.
Definition: ilActivity.php:15
$params
Definition: example_049.php:96
getContext()
Returns a reference to the parent node.
setIncludeFilename($filename)
Sets the name of the file to be included prior to calling the method.