Back to ContentType class

Method getContentTable

public mixed
getContentTable
()
Method to get the Table object for the content type from the table object.
Returns
  • mixed Table object on success, otherwise false.
Since
  • 3.2
-
  • \RuntimeException
Class: ContentType
Project: Joomla

Method getContentTable - Source code

/**
 * Method to get the Table object for the content type from the table object.
 *
 * @return  mixed  Table object on success, otherwise false.
 *
 * @since   3.2
 *
 * @throws  \RuntimeException
 */
public function getContentTable()
{
    $result = false;
    $tableInfo = json_decode($this->table);
    if (\is_object($tableInfo) && isset($tableInfo->special)) {
        if (\is_object($tableInfo->special) && isset($tableInfo->special->type) && isset($tableInfo->special->prefix)) {
            $class = $tableInfo->special->class ?? 'Joomla\\CMS\\Table\\Table';
            if (!class_implements($class, 'Joomla\\CMS\\Table\\TableInterface')) {
                // This isn't an instance of TableInterface. Abort.
                throw new \RuntimeException('Class must be an instance of Joomla\\CMS\\Table\\TableInterface');
            }
            $result = $class::getInstance($tableInfo->special->type, $tableInfo->special->prefix);
        }
    }
    return $result;
}