Element_OphTrOperationbooking_Operation::setStatus PHP Méthode

setStatus() public méthode

Set the status based on the name passed in. If $save is false, we don't save and it is the responsibility of the caller to ensure the instance is saved.
public setStatus ( $name, boolean $save = true )
$name
$save boolean
    public function setStatus($name, $save = true)
    {
        if (!($status = OphTrOperationbooking_Operation_Status::model()->find('name=?', array($name)))) {
            throw new Exception('Invalid status: ' . $name);
        }
        $this->status_id = $status->id;
        if ($save && !$this->save()) {
            throw new Exception('Unable to change operation status: ' . print_r($this->getErrors(), true));
        }
    }