Back to Menu class

Method check

public bool
check
()
Overloaded check function
Returns
  • bool True on success
Since
  • 1.5
-
  • \Joomla\CMS\Table\Table::check()
Class: Menu
Project: Joomla

Method check - Source code

/**
 * Overloaded check function
 *
 * @return  boolean  True on success
 *
 * @see     Table::check()
 * @since   1.5
 */
public function check()
{
    try {
        parent::check();
    } catch (\Exception $e) {
        $this->setError($e->getMessage());
        return false;
    }
    // Check for a title.
    if ($this->title === null || trim($this->title) === '') {
        $this->setError(Text::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_MENUITEM'));
        return false;
    }
    // Check for a path.
    if ($this->path === null || trim($this->path) === '') {
        $this->path = $this->alias;
    }
    // Check for params.
    if ($this->params === null || trim($this->params) === '') {
        $this->params = '{}';
    }
    // Check for img.
    if ($this->img === null || trim($this->img) === '') {
        $this->img = ' ';
    }
    // Cast the home property to an int for checking.
    $this->home = (int) $this->home;
    // Verify that the home item is a component.
    if ($this->home && $this->type !== 'component') {
        $this->setError(Text::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT'));
        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;
    }
    return true;
}