| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Traits;
- /**
- *
- * Created by PhpStorm.
- * User: Tomasz Bielecki ( tomasz.bi@thurdata.com )
- * Date: 08.10.19
- * Time: 11:22
- * Class ProcesStepHandler
- */
- trait ProcessStepHandler
- {
- /**
- * array with process in progress
- * @var array
- */
- protected $inProgressProcess = [];
- /**
- * array with completed process
- * @var array
- */
- protected $completedProcess = [];
- /**
- * array with process finished with error status
- * @var array
- */
- protected $errorProcess = [];
- /**
- * @var array
- */
- protected $allProcess = [];
- /**
- * @return array
- */
- public function getInProgress()
- {
- return $this->inProgressProcess;
- }
- /**
- * @return array
- */
- public function getCompleted()
- {
- return $this->completedProcess;
- }
- /**
- * @return array
- */
- public function getErrorProcess()
- {
- return $this->errorProcess;
- }
- /**
- * @return array
- */
- public function getAllProcess()
- {
- return $this->allProcess;
- }
- /**
- * @param $code
- * @return $this
- */
- public function startProcess($code)
- {
- $this->inProgressProcess[$code] = $code;
- $this->allProcess[] = $code;
- return $this;
- }
- /**
- * @param $code
- * @return $this
- */
- public function stopProcess($code)
- {
- unset($this->inProgressProcess[$code]);
- $this->completedProcess[$code] = $code;
- return $this;
- }
- /**
- * @param $code
- * @param $error
- * @return $this
- */
- public function stopProcessWithError($code, $error)
- {
- unset($this->inProgressProcess[$code]);
- $this->error[$code] = ['code' => $code, 'error' => $error];
- return $this;
- }
- /**
- * @return array
- */
- public function info()
- {
- return [
- 'process' => $this->getAllProcess(),
- 'inProgress' => $this->getInProgress(),
- 'finished' => $this->getCompleted(),
- 'error' => $this->getErrorProcess(),
- ];
- }
- }
|