DBServer::suspend PHP Method

suspend() public method

Marks server as to be suspended.
public suspend ( string | array $reason, boolean $forcefully = null, Scalr_Account_User | integer $user = null )
$reason string | array The reason possibly with the format parameters.
$forcefully boolean optional Method: forcefully (true) | gracefully (false)
$user Scalr_Account_User | integer optional The user object or its unique identifier
    public function suspend($reason, $forcefully = null, $user = null)
    {
        if (!in_array($this->status, array(SERVER_STATUS::RUNNING))) {
            return;
        }
        $forcefully = $forcefully === null ? true : (bool) $forcefully;
        //Ensures handling identifier of the user instead of the object
        if ($user !== null && !$user instanceof \Scalr_Account_User) {
            try {
                $user = Scalr_Account_User::init()->loadById(intval($user));
            } catch (\Exception $e) {
            }
        }
        $reason = 'TODO';
        //Set who does terminate the server
        if ($user instanceof \Scalr_Account_User) {
            $this->SetProperties(array(\SERVER_PROPERTIES::TERMINATED_BY_ID => $user->id, \SERVER_PROPERTIES::TERMINATED_BY_EMAIL => $user->getEmail()));
        }
        $this->update(['status' => SERVER_STATUS::PENDING_SUSPEND, 'dateShutdownScheduled' => date("Y-m-d H:i:s", $forcefully ? time() : strtotime(Scalr::config('scalr.system.server_terminate_timeout')))]);
        //$this->getServerHistory()->markAsTerminated($reason);
        //$this->getServerHistory()->markAsSuspended($reason);
        if (isset($this->farmId) && !$forcefully) {
            Scalr::FireEvent($this->farmId, new BeforeHostTerminateEvent($this, true));
        }
    }