LFT
  • Namespace
  • Class
  • Tree

Namespaces

  • Docoflow
    • Contracts
    • Entity
    • Facades
    • Models
    • Traits
  • Docolight
    • Agno
      • Traits
    • Container
    • Http
      • Contracts
    • Rest
      • Handler
      • Http
    • Support
      • Debug
      • Traits
  • Docotory
    • Traits
  • None

Classes

  • Docoflow\Docoflow
  • Docoflow\Entity\Group
  • Docoflow\Entity\Step
  • Docoflow\Entity\Verificator
  • Docoflow\Facades\Action
  • Docoflow\Facades\Activity
  • Docoflow\Facades\Flo
  • Docoflow\Facades\StateActivity
  • Docoflow\Flo
  • Docoflow\Models\Workflow
  • Docoflow\Models\WorkflowAction
  • Docoflow\Models\WorkflowActivity
  • Docoflow\Models\WorkflowGroups
  • Docoflow\Models\WorkflowNotification
  • Docoflow\Models\WorkflowState
  • Docoflow\Models\WorkflowStateActivity
  • Docoflow\Models\WorkflowStep
  • Docoflow\Models\WorkflowVerificator
  • Docolight
  • Docolight\Agno\AgnoModule
  • Docolight\Container\Container
  • Docolight\Http\Headers
  • Docolight\Http\JsonResponse
  • Docolight\Http\MimeResponse
  • Docolight\Http\Response
  • Docolight\Http\ResponseFactory
  • Docolight\Rest\Handler\RestfulErrorHandler
  • Docolight\Rest\Http\RestFulController
  • Docolight\Support\ActiveRecordWrapper
  • Docolight\Support\Arr
  • Docolight\Support\Carbonate
  • Docolight\Support\ClassLoader
  • Docolight\Support\Collection
  • Docolight\Support\CollectionDataProvider
  • Docolight\Support\Debug\Dumper
  • Docolight\Support\Debug\HtmlDumper
  • Docolight\Support\Facade
  • Docolight\Support\Factory
  • Docolight\Support\Fluent
  • Docolight\Support\Html
  • Docolight\Support\IterablePager
  • Docolight\Support\Repository
  • Docolight\Support\Set
  • Docolight\Support\Str
  • Docotory\Factory

Interfaces

  • Docoflow\Contracts\DocoflowContract
  • Docoflow\Contracts\ValidationStatus
  • Docolight\Http\Contracts\Arrayable

Traits

  • Docoflow\Traits\BulkValidator
  • Docoflow\Traits\Entity
  • Docoflow\Traits\HasMutator
  • Docoflow\Traits\Validable
  • Docolight\Agno\Traits\HasAssetsUrl
  • Docolight\Agno\Traits\HasAutoload
  • Docolight\Support\Traits\Macroable
  • Docotory\Traits\HasFactories

Exceptions

  • Docolight\Container\BindingResolutionException
  • Docotory\ResolvingTypeException

Functions

  • array_add
  • array_build
  • array_collapse
  • array_divide
  • array_dot
  • array_except
  • array_first
  • array_flatten
  • array_forget
  • array_get
  • array_has
  • array_last
  • array_only
  • array_pluck
  • array_pull
  • array_replace_value
  • array_set
  • array_sort
  • array_sort_recursive
  • array_where
  • cache
  • camel_case
  • class_basename
  • class_uses_recursive
  • collect
  • container
  • data_get
  • dd
  • def
  • dump
  • e
  • ends_with
  • fluent
  • get
  • head
  • input
  • last
  • object_get
  • preg_replace_sub
  • request
  • response
  • session
  • snake_case
  • starts_with
  • str_contains
  • str_finish
  • str_is
  • str_limit
  • str_random
  • str_replace_array
  • str_slug
  • studly_case
  • title_case
  • trait_uses_recursive
  • transaction
  • trimtolower
  • value
  • with
  1 <?php
  2 
  3 namespace Docoflow\Entity;
  4 
  5 use Exception;
  6 use Docoflow\Traits\Entity;
  7 use Docolight\Support\Collection;
  8 
  9 /**
 10  * Group entities.
 11  *
 12  * @author Krisan Alfa Timur <krisanalfa@docotel.co.id>
 13  */
 14 class Group extends Collection
 15 {
 16     use Entity;
 17 
 18     /**
 19      * Rebuild a barely new group to a readable array.
 20      *
 21      * @param \Docoflow\Entity\Step &$steps
 22      *
 23      * @return \Docoflow\Entity\Group
 24      */
 25     public function rebuild(Step &$steps)
 26     {
 27         $groups = new static;
 28 
 29         foreach ($this as $group) {
 30             $group = fluent($group);
 31 
 32             if (! $groupId = $group->{'$id'}) {
 33                 throw new Exception("Group doesn't have an id.");
 34             }
 35 
 36             if (! $assignedStep = $group->{'$step'}) {
 37                 throw new Exception("Group doesn't have any assigned step id.");
 38             }
 39 
 40             if ($steps->has($assignedStep)) {
 41                 if ($steps->get($assignedStep)->groups->has($groupId)) {
 42                     throw new Exception("Group id [$groupId] has been assigned before and it can't be overriden.");
 43                 }
 44 
 45                 $group->verificator = new Verificator();
 46 
 47                 $groups->offsetSet($groupId, $group);
 48 
 49                 $steps->pushGroup($groupId, $group);
 50                 $steps->get($assignedStep)->groups->offsetSet($groupId, $group);
 51             } else {
 52                 throw new Exception("Assigned step [$assignedStep] doesn't exist.");
 53             }
 54         }
 55 
 56         return $groups;
 57     }
 58 
 59     /**
 60      * Gather all verificator in current group
 61      *
 62      * @return \Docoflow\Entity\Verificator
 63      */
 64     public function gatherVerificators()
 65     {
 66         $verificators = new Verificator();
 67 
 68         foreach ($this as $group) {
 69             $verificators->assign($group->getRelated('verificators'));
 70         }
 71 
 72         return $verificators;
 73     }
 74 
 75     /**
 76      * Approve all.
 77      *
 78      * @return mixed
 79      */
 80     public function approve()
 81     {
 82         $this->gatherVerificators()->approve();
 83 
 84         return $this;
 85     }
 86 
 87     /**
 88      * Approve all if it's not expired.
 89      *
 90      * @return mixed
 91      */
 92     public function approveIf()
 93     {
 94         $this->gatherVerificators()->approveIf();
 95 
 96         return $this;
 97     }
 98 
 99     /**
100      * Reject all.
101      *
102      * @return mixed
103      */
104     public function reject()
105     {
106         $this->gatherVerificators()->reject();
107 
108         return $this;
109     }
110 
111     /**
112      * Reject all if it's not expired.
113      *
114      * @return mixed
115      */
116     public function rejectIf()
117     {
118         $this->gatherVerificators()->rejectIf();
119 
120         return $this;
121     }
122 
123     /**
124      * Reset all.
125      *
126      * @return mixed
127      */
128     public function reset()
129     {
130         $this->gatherVerificators()->reset();
131 
132         return $this;
133     }
134 
135     /**
136      * Reset all if it's not expired.
137      *
138      * @return mixed
139      */
140     public function resetIf()
141     {
142         $this->gatherVerificators()->resetIf();
143 
144         return $this;
145     }
146 }
147 
LFT API documentation generated by ApiGen