Kraken\Runtime\RuntimeModel::setLoopState PHP Method

setLoopState() protected method

protected setLoopState ( integer $state )
$state integer
    protected function setLoopState($state)
    {
        if ($state === $this->loopState) {
            return;
        }
        switch ($state) {
            case self::LOOP_STATE_STOPPED:
                $this->stopLoop();
                break;
            case self::LOOP_STATE_STARTED:
                $this->stopLoop();
                if ($this->loopState === self::LOOP_STATE_FAILED) {
                    $this->getLoop()->import($this->loopBackup);
                }
                break;
            case self::LOOP_STATE_FAILED:
                $this->stopLoop();
                if ($this->loopState === self::LOOP_STATE_STARTED) {
                    $this->getLoop()->export($this->loopBackup);
                    $this->getLoop()->erase();
                }
                break;
            default:
                throw new LogicException('Method RuntimeModel::setLoopState() tried switching to invalid state.');
        }
        $this->loopState = $this->loopNextState = $state;
    }