public function onSuccess() { $name = $this->getValue('name'); $title = $this->getValue('title'); $backend = $this->getValue('backend'); if ($this->config === null) { // New config $config = new BusinessProcess(); $config->setName($name); if ($title) { $config->setTitle($title); } if ($backend) { $config->setBackendName($backend); } if ($this->getValue('state_type') === 'soft') { $config->useSoftStates(); } else { $config->useHardStates(); } $this->storage->storeProcess($config); $config->clearAppliedChanges(); $this->setRedirectUrl($this->getRedirectUrl()->setParams(array('config' => $name, 'unlocked' => true))); Notification::success(sprintf('Process %s has been created', $name)); } else { // Existing config $config = $this->config; if ($title) { $config->setTitle($title); } if ($backend) { $config->setBackendName($backend); } if ($this->getValue('state_type') === 'soft') { $config->useSoftStates(); } else { $config->useHardStates(); } $this->storage->storeProcess($config); $config->clearAppliedChanges(); $this->getRedirectUrl()->setParam('config', $name); Notification::success(sprintf('Process %s has been stored', $name)); } }
/** * @return BusinessProcess */ public function loadProcess($name) { Benchmark::measure('Loading business process ' . $name); $bp = new BusinessProcess(); $bp->setName($name); $this->parseFile($name, $bp); $this->loadHeader($name, $bp); Benchmark::measure('Business process ' . $name . ' loaded'); return $bp; }