Back to UCMType class

Method getTypeByTable

public mixed
getTypeByTable
(mixed $tableName)
Get the Content Type from the table class name
Parameters
  • string $tableName The table for the type
Returns
  • mixed The UCM Type data if found, false if no match is found
Since
  • 3.2
Class: UCMType
Project: Joomla

Method getTypeByTable - Source code

/**
 * Get the Content Type from the table class name
 *
 * @param   string  $tableName  The table for the type
 *
 * @return  mixed  The UCM Type data if found, false if no match is found
 *
 * @since   3.2
 */
public function getTypeByTable($tableName)
{
    $query = $this->db->getQuery(true)->select($this->db->quoteName('ct') . '.*')->from($this->db->quoteName('#__content_types', 'ct'));
    $this->db->setQuery($query);
    $types = $this->db->loadObjectList();
    foreach ($types as $type) {
        $tableFromType = json_decode($type->table);
        $tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;
        if ($tableNameFromType === $tableName) {
            return $type;
        }
    }
    return false;
}