|
@@ -380,7 +380,6 @@ class Workflow
|
|
|
public function postPersist(LifecycleEventArgs $event)
|
|
|
{
|
|
|
$this->updateWorkflows();
|
|
|
- $this->reloadCache();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -389,16 +388,25 @@ class Workflow
|
|
|
public function postUpdate(LifecycleEventArgs $event)
|
|
|
{
|
|
|
$this->updateWorkflows();
|
|
|
- $this->reloadCache();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\PreRemove
|
|
|
*/
|
|
|
public function preRemove(LifecycleEventArgs $event)
|
|
|
{
|
|
|
$this->updateWorkflows();
|
|
|
- $this->reloadCache();
|
|
|
+ }
|
|
|
+
|
|
|
+ // La idea era peticionar el comando y que actualice, pero desde aquí, el comando no obtiene el enable actualizado.
|
|
|
+ public function updateWorkflowsCommand()
|
|
|
+ {
|
|
|
+ global $kernel;
|
|
|
+
|
|
|
+ $console = $kernel->getRootDir()."/../bin/console";
|
|
|
+
|
|
|
+ exec("php {$console} workflow:generate:list");
|
|
|
+ exec("php {$console} cache:clear --env=prod");
|
|
|
}
|
|
|
|
|
|
public function updateWorkflows()
|
|
@@ -406,17 +414,34 @@ class Workflow
|
|
|
global $kernel;
|
|
|
|
|
|
$em = $kernel->getContainer()->get("doctrine.orm.entity_manager");
|
|
|
- $workflows = $em->getRepository("WorkflowBundle:Workflow")->findBy(array("enable"=>1));
|
|
|
+ $workflows = $em->getRepository("WorkflowBundle:Workflow")->findBy(array('enable'=>1));
|
|
|
+
|
|
|
+ $rootDir = $kernel->getRootDir();
|
|
|
|
|
|
$workflow_template = array();
|
|
|
$workflow_template['framework'] = array();
|
|
|
|
|
|
$templates = array();
|
|
|
foreach($workflows as $k => $workflow) {
|
|
|
- $templates[$workflow->getName()] = Yaml::parse($workflow->getTemplate());
|
|
|
+
|
|
|
+ $body = array();
|
|
|
+
|
|
|
+ $body['type'] = $workflow->getType();
|
|
|
+
|
|
|
+ if(is_array($workflow->getMarkingName())) {
|
|
|
+ $markingName = $workflow->getMarkingName();
|
|
|
+ } else {
|
|
|
+ $markingName = array(0 => $workflow->getMarkingName());
|
|
|
+ }
|
|
|
+ $body['marking_store'] = array('type' => $workflow->getMarkingType(), 'arguments' => $markingName);
|
|
|
+
|
|
|
+ $body += Yaml::parse($workflow->getTemplate());
|
|
|
+
|
|
|
+ $templates[$workflow->getName()] = $body;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- $workflow_file = $kernel->getRootDir()."/Resources/workflows/workflow_list.yml";
|
|
|
+ $workflow_file = $rootDir."/Resources/workflows/workflow_list.yml";
|
|
|
|
|
|
$handle = fopen($workflow_file,"w+");
|
|
|
|
|
@@ -430,15 +455,10 @@ class Workflow
|
|
|
|
|
|
fclose($handle);
|
|
|
chmod($workflow_file, 0777);
|
|
|
- }
|
|
|
|
|
|
- public function reloadCache()
|
|
|
- {
|
|
|
- global $kernel;
|
|
|
-
|
|
|
- $console = $kernel->getRootDir()."/../bin/console";
|
|
|
+ $console = $rootDir."/../bin/console";
|
|
|
+ exec("php {$console} cache:clear --env=prod");
|
|
|
|
|
|
- exec("{$console} cache:clear --env=prod");
|
|
|
}
|
|
|
|
|
|
}
|