Back to Module class

Method check

public bool
check
()
Overloaded check function.
Returns
  • bool True if the instance is sane and able to be stored in the database.
Since
  • 1.5
-
  • \Joomla\CMS\Table\Table::check()
Class: Module
Project: Joomla

Method check - Source code

/**
 * Overloaded check function.
 *
 * @return  boolean  True if the instance is sane and able to be stored in the database.
 *
 * @see     Table::check()
 * @since   1.5
 */
public function check()
{
    try {
        parent::check();
    } catch (\Exception $e) {
        $this->setError($e->getMessage());
        return false;
    }
    // Check for valid name
    if (trim($this->title) === '') {
        $this->setError(Text::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_MODULE'));
        return false;
    }
    // Set publish_up, publish_down to null if not set
    if (!$this->publish_up) {
        $this->publish_up = null;
    }
    if (!$this->publish_down) {
        $this->publish_down = null;
    }
    // Prevent to save too large content > 65535
    if (\strlen($this->content) > 65535 || \strlen($this->params) > 65535) {
        $this->setError(Text::_('COM_MODULES_FIELD_CONTENT_TOO_LARGE'));
        return false;
    }
    // Check the publish down date is not earlier than publish up.
    if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
        // Swap the dates.
        $temp = $this->publish_up;
        $this->publish_up = $this->publish_down;
        $this->publish_down = $temp;
    }
    return true;
}