Refactoring Bpmn/Workflow handling layer (1st commit)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use ProcessMaker\Project\ProjectHandler;
|
||||
|
||||
class BpmnProject extends ProjectHandler
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use ProcessMaker\Project\Adapter\BpmnHandler;
|
||||
|
||||
class WorkflowBpmnProject extends BpmnHandler
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use \Process;
|
||||
use \Task;
|
||||
|
||||
use ProcessMaker\Project\ProjectHandler;
|
||||
|
||||
class WorkflowProject extends ProjectHandler
|
||||
{
|
||||
public function create($data)
|
||||
{
|
||||
try {
|
||||
// setting defaults
|
||||
$data['TASKS'] = array_key_exists('TASKS', $data) ? $data['TASKS'] : array();
|
||||
$data['ROUTES'] = array_key_exists('ROUTES', $data) ? $data['ROUTES'] : array();
|
||||
|
||||
// Create project
|
||||
$process = new Process();
|
||||
$proUid = $process->create($data, false);
|
||||
|
||||
// Create project's tasks
|
||||
foreach ($data['TASKS'] as $taskData) {
|
||||
$taskData['PRO_UID'] = $proUid;
|
||||
$task = new Task();
|
||||
$task->create($taskData, false);
|
||||
}
|
||||
|
||||
// Create project's routes
|
||||
foreach ($data['ROUTES'] as $route) {
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
//throw new \RuntimeException($e);
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
echo $e->getTraceAsString() . PHP_EOL;
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
public function update($prjUid, $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
}
|
||||
|
||||
public function delete($prjUid)
|
||||
{
|
||||
// TODO: Implement delete() method.
|
||||
}
|
||||
|
||||
public function load($prjUid)
|
||||
{
|
||||
// TODO: Implement load() method.
|
||||
}
|
||||
}
|
||||
35
workflow/engine/src/ProcessMaker/Project/ProjectHandler.php
Normal file
35
workflow/engine/src/ProcessMaker/Project/ProjectHandler.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project;
|
||||
|
||||
use ProcessMaker\Util\Logger;
|
||||
|
||||
abstract class ProjectHandler implements ProjectHandlerInterface
|
||||
{
|
||||
public abstract function create($data);
|
||||
public abstract function update($prjUid, $data);
|
||||
public abstract function delete($prjUid);
|
||||
public abstract function load($prjUid);
|
||||
|
||||
/**
|
||||
* Log in ProcessMaker Standard Output if debug mode is enabled.
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik at icloud dot com>
|
||||
* @internal param $args this method receives N-Arguments dynamically with any type, string, array, object, etc
|
||||
* it means that you ca use it by example:
|
||||
*
|
||||
* self::log("Beginning transaction");
|
||||
* self::log("Method: ", __METHOD__, 'Returns: ', $result);
|
||||
*
|
||||
*/
|
||||
public static function log()
|
||||
{
|
||||
if (System::isDebugMode()) {
|
||||
|
||||
$me = Logger::getInstance();
|
||||
$args = func_get_args();
|
||||
//array_unshift($args, 'Class '.__CLASS__.' ');
|
||||
|
||||
call_user_func_array(array($me, 'setLog'), $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project;
|
||||
|
||||
interface ProjectHandlerInterface
|
||||
{
|
||||
public function create($data);
|
||||
public function update($prjUid, $data);
|
||||
public function delete($prjUid);
|
||||
public function load($prjUid);
|
||||
}
|
||||
Reference in New Issue
Block a user