Node::beforeSave PHP Method

beforeSave() public method

beforeSave callback
public beforeSave ( $options = [] ) : boolean
return boolean
    public function beforeSave($options = array())
    {
        if (empty($this->data[$this->alias]['type']) && $this->type != null) {
            $this->data[$this->alias]['type'] = $this->type;
        }
        $dateFields = array('created');
        foreach ($dateFields as $dateField) {
            if (!array_key_exists($dateField, $this->data[$this->alias])) {
                continue;
            }
            if (empty($this->data[$this->alias][$dateField])) {
                $db = $this->getDataSource();
                $colType = array_merge(array('formatter' => 'date'), $db->columns[$this->getColumnType($dateField)]);
                $this->data[$this->alias][$dateField] = call_user_func($colType['formatter'], $colType['format']);
            }
        }
        return true;
    }