Back to CoreContent class

Method store

public bool
store
(mixed $updateNulls = true)
Overrides Table::store to set modified data and user id.
Parameters
  • bool $updateNulls True to update fields even if they are null.
Returns
  • bool True on success.
Since
  • 3.1
Class: CoreContent
Project: Joomla

Method store - Source code

/**
 * Overrides Table::store to set modified data and user id.
 *
 * @param   boolean  $updateNulls  True to update fields even if they are null.
 *
 * @return  boolean  True on success.
 *
 * @since   3.1
 */
public function store($updateNulls = true)
{
    $date = Factory::getDate();
    $user = Factory::getUser();
    if ($this->core_content_id) {
        // Existing item
        $this->core_modified_time = $date->toSql();
        $this->core_modified_user_id = $user->get('id');
        $isNew = false;
    } else {
        // New content item. A content item core_created_time and core_created_user_id field can be set by the user,
        // so we don't touch either of these if they are set.
        if (!(int) $this->core_created_time) {
            $this->core_created_time = $date->toSql();
        }
        if (empty($this->core_created_user_id)) {
            $this->core_created_user_id = $user->get('id');
        }
        if (!(int) $this->core_modified_time) {
            $this->core_modified_time = $this->core_created_time;
        }
        if (empty($this->core_modified_user_id)) {
            $this->core_modified_user_id = $this->core_created_user_id;
        }
        $isNew = true;
    }
    $oldRules = $this->getRules();
    if (empty($oldRules)) {
        $this->setRules('{}');
    }
    $result = parent::store($updateNulls);
    return $result && $this->storeUcmBase($updateNulls, $isNew);
}