Beispiel #1
0
 /**
  * Rebuild a barely new group to a readable array.
  *
  * @param \Docoflow\Entity\Step &$steps
  *
  * @return \Docoflow\Entity\Group
  */
 public function rebuild(Step &$steps)
 {
     $groups = new static();
     foreach ($this as $group) {
         $group = fluent($group);
         if (!($groupId = $group->{'$id'})) {
             throw new Exception("Group doesn't have an id.");
         }
         if (!($assignedStep = $group->{'$step'})) {
             throw new Exception("Group doesn't have any assigned step id.");
         }
         if ($steps->has($assignedStep)) {
             if ($steps->get($assignedStep)->groups->has($groupId)) {
                 throw new Exception("Group id [{$groupId}] has been assigned before and it can't be overriden.");
             }
             $group->verificator = new Verificator();
             $groups->offsetSet($groupId, $group);
             $steps->pushGroup($groupId, $group);
             $steps->get($assignedStep)->groups->offsetSet($groupId, $group);
         } else {
             throw new Exception("Assigned step [{$assignedStep}] doesn't exist.");
         }
     }
     return $groups;
 }
Beispiel #2
0
 /**
  * Rebuild a barely new group to a readable array.
  *
  * @param \Docoflow\Entity\Step &$steps
  */
 public function rebuild(Step &$steps)
 {
     foreach ($this as $verificator) {
         $verificator = fluent($verificator);
         if (!($assignedGroup = $verificator->{'$group'})) {
             throw new Exception("Verificator hasn't assigned to any group.");
         }
         if ($steps->hasGroup($assignedGroup)) {
             $verificatorStep = $steps->getGroup($assignedGroup)->{'$step'};
             $steps->get($verificatorStep)->groups->get($assignedGroup)->verificator->push($verificator);
         } else {
             throw new Exception("Assigned group [{$assignedGroup}] doent't exist.");
         }
     }
 }