FOF30\Model\DataModel::publish PHP Method

publish() public method

Change the publish state of a record. By default it will set it to 1 (published) unless you specify a different value.
public publish ( integer $state = 1 )
$state integer The publish state. Default: 1 (published).
    public function publish($state = 1)
    {
        if (!$this->getId()) {
            throw new RecordNotLoaded("Can't change the state of a not loaded DataModel");
        }
        if (!$this->hasField('enabled')) {
            return $this;
        }
        $this->triggerEvent('onBeforePublish', array());
        $enabled = $this->getFieldAlias('enabled');
        $this->{$enabled} = $state;
        $this->save();
        $this->triggerEvent('onAfterPublish');
        return $this;
    }