FOF30\Model\DataModel::copy PHP Method

copy() public method

Creates a copy of the current record. After the copy is performed, the data model contains the data of the new record.
public copy ( $data = null ) : DataModel
return DataModel
    public function copy($data = null)
    {
        $this->triggerEvent('onBeforeCopy');
        $this->{$this->idFieldName} = null;
        if ($this->hasField('created_by')) {
            $this->setFieldValue('created_by', null);
        }
        if ($this->hasField('modified_by')) {
            $this->setFieldValue('modified_by', null);
        }
        if ($this->hasField('locked_by')) {
            $this->setFieldValue('locked_by', null);
        }
        if ($this->hasField('created_on')) {
            $this->setFieldValue('created_on', null);
        }
        if ($this->hasField('modified_on')) {
            $this->setFieldValue('modified_on', null);
        }
        if ($this->hasField('locked_on')) {
            $this->setFieldValue('locked_on', null);
        }
        $result = $this->save($data);
        $this->triggerEvent('onAfterCopy', array(&$result));
        return $result;
    }