Switch active state by code
@param string $sStateCode
187594
public function switchState($sStateCode)
    {
        if (empty($sStateCode) || !PluginManager::instance()->hasPlugin('RainLab.Location')) {
            return;
        }

        $this->obActiveState = \RainLab\Location\Models\State::whereCode($sStateCode)->first();
    }
1011557
public function checkCode($code)
    {
        $res = $this->twofactorAdapter->check($code);

        if($res)
        {
            setcookie('twofactorDir-' . $this->dir, $this->cookieCode, 0, "/");
            self::redirect();
        }

        return $res;
    }
1307024
public function user($code = null)
    {
        if ($this->hasInvalidState()) {
            throw new InvalidStateException();
        }

        $params = [
            'code' => $code ?: $this->request->get('code'),
        ];

        return $this->parseJSON('get', [self::API_GET_USER_INFO, $params]);
    }
987562
public function swi($condition, $value = null) {
		if (null == $value) {
			$this->_switchCondition = null;
			$this->_switchValue = $condition;
		} else  {
			$this->_switchCondition = $condition;
			$this->_switchValue = $value;
		}
	}
741260
public static function send_status($code) {
	if (!isset(static::$status_messages[$code])) {
		$code = self::STATUS_INTERNAL_SERVER_ERROR;
	}
	
	http_response_code($code);
}
62347
public function set_state($state) {
        if ($state != $this->_state + 1 || $state > self::STATE_DONE) {
            throw new coding_exception('Invalid state passed to moodle_page::set_state. We are in state ' .
                    $this->_state . ' and state ' . $state . ' was requested.');
        }

        if ($state == self::STATE_PRINTING_HEADER) {
            $this->starting_output();
        }

        $this->_state = $state;
    }
8847
public function setStatusCode($code = null)
    {
        if (!empty($code)) {
            $this->_statusCode = $code;
            http_response_code($this->_statusCode); // this sends the http status code
        }
    }
1184623
public function setStatus($code, $reasonPhrase = '')
    {
        $codeGroup = ResponseCode::getGroupFromCode($code);

        if ($codeGroup !== ResponseCode::GROUP_CLIENT_ERROR && $codeGroup !== ResponseCode::GROUP_SERVER_ERROR) {
            throw new \LogicException(__CLASS__ . ' accepts error codes only (4xx & 5xx).');
        }

        parent::setStatus($code, $reasonPhrase);
    }
429495
@Override
    public void setState(PowerState state) {
        switch(state) {
            case OFF: {
                if(!isOff()) {

                    // apply the new pin state
                    pin.setState(offState);
                }
                break;
            }
            case ON: {
                if(!isOn()) {

                    // apply the new pin state
                    pin.setState(onState);
                }
                break;
            }
            default: {
                throw new UnsupportedOperationException("Cannot set power state: " + state.toString());
            }
        }
    }
768885
public function statusCodeEquals($code)
    {
        $actual = $this->session->getStatusCode();
        $message = sprintf('Current response status code is %d, but %d expected.', $actual, $code);

        $this->assert(intval($code) === intval($actual), $message);
    }
62748
public function setStatusHeader($code = 200)
    {
        if (!$this->controller->canEnd()) {
            return;
        }
        $this->response->status($code);
        return $this;
    }
1027745
public function withStatus($code, $reasonPhrase = '')
    {
        $status = clone $this;
        $status->setStatus($code, $reasonPhrase);
        
        return $status;
    }
153366
public void addState(String name, String code)
    {
    	states.add(new State(this, name, code));
    }
175969
public function setStatusCode($code)
	{
		if (!array_key_exists($code, self::$statusCodeMap)) {
			throw new InvalidArgumentException(sprintf('The HTTP stauts code %s is unknown.', $code));
		}

		$this->statusCode = $code;

		return $this;
	}
1048250
final public function hasIPNStatusCode($sStatusCode)
    {
        $oStatusCode = TdbPkgShopPaymentIpnMessage::getMessageForOrder($this, $sStatusCode);
        $bHasStatusCode = (null !== $oStatusCode);

        return $bHasStatusCode;
    }
851821
public function setStateCodeAttribute($code)
    {
        if (!$state = State::whereCode($code)->first()) {
            return;
        }

        $this->model->state = $state;
    }
11439
public function setCode( $code = null)
	{
		// Require that the response be unlocked before changing it
		$this->requireUnlocked();
		$this->status = new Status($code);
		return $this;
	}