public static function construct(BusinessProcess $bp, Session $session)
 {
     $key = 'changes.' . $bp->getName();
     $changes = new ProcessChanges();
     $changes->sessionKey = $key;
     if ($actions = $session->get($key)) {
         foreach ($actions as $string) {
             $changes->push(NodeAction::unserialize($string));
         }
     }
     $changes->session = $session;
     return $changes;
 }
 protected function loadModifiedBpConfig()
 {
     $bp = $this->loadBpConfig();
     $changes = ProcessChanges::construct($bp, $this->session());
     if ($this->params->get('dismissChanges')) {
         Notification::success(sprintf($this->translate('%d pending change(s) have been dropped'), $changes->count()));
         $changes->clear();
         $this->redirectNow($this->url()->without('dismissChanges')->without('unlocked'));
     }
     $bp->applyChanges($changes);
     return $bp;
 }
 public function onSuccess()
 {
     $changes = ProcessChanges::construct($this->process, $this->session);
     $modifications = array();
     $children = $this->getValue('children');
     $alias = $this->getValue('alias');
     $operator = $this->getValue('operator');
     $display = $this->getValue('display');
     $url = $this->getValue('url');
     if (empty($url)) {
         $url = null;
     }
     if (empty($alias)) {
         $alias = null;
     }
     ksort($children);
     // TODO: rename
     if ($node = $this->node) {
         if ($display !== $node->getDisplay()) {
             $modifications['display'] = $display;
         }
         if ($operator !== $node->getOperator()) {
             $modifications['operator'] = $operator;
         }
         if ($children !== $node->getChildNames()) {
             $modifications['childNames'] = $children;
         }
         if ($url !== $node->getInfoUrl()) {
             $modifications['infoUrl'] = $url;
         }
         if ($alias !== $node->getAlias()) {
             $modifications['alias'] = $alias;
         }
     } else {
         $modifications = array('display' => $display, 'operator' => $operator, 'childNames' => $children, 'infoUrl' => $url, 'alias' => $alias);
     }
     if (!empty($modifications)) {
         if ($this->node === null) {
             $changes->createNode($this->getValue('name'), $modifications);
         } else {
             $changes->modifyNode($this->node, $modifications);
         }
         Notification::success(sprintf('Process %s has been modified', $this->process->getName()));
     }
 }
 public function applyChanges(ProcessChanges $changes)
 {
     $cnt = 0;
     foreach ($changes->getChanges() as $change) {
         $cnt++;
         $change->applyTo($this);
     }
     $this->changeCount = $cnt;
     $this->appliedChanges = $changes;
     return $this;
 }