FOF30\Model\DataModel::unpublish PHP Method

unpublish() public method

Unpublish the record, i.e. set enabled to 0
public unpublish ( )
    public function unpublish()
    {
        if (!$this->getId()) {
            throw new RecordNotLoaded("Can't unpublish a not loaded DataModel");
        }
        if (!$this->hasField('enabled')) {
            return $this;
        }
        $this->triggerEvent('onBeforeUnpublish', array());
        $enabled = $this->getFieldAlias('enabled');
        $this->{$enabled} = 0;
        $this->save();
        $this->triggerEvent('onAfterUnpublish');
        return $this;
    }