FOF30\Model\DataModel::archive PHP Method

archive() public method

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