public \Joomla\CMS\Table\Table
createTable
(mixed $name, mixed $prefix = '', array $config = [])
/**
* Method to load and return a table object.
*
* @param string $name The name of the table.
* @param string $prefix Optional table prefix.
* @param array $config Optional configuration array for the table.
*
* @return \Joomla\CMS\Table\Table The table object
*
* @since 3.10.0
* @throws \Exception
*/
public function createTable($name, $prefix = '', array $config = [])
{
// Clean the parameters
$name = preg_replace('/[^A-Z0-9_]/i', '', $name);
$prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
if (!$prefix) {
@trigger_error(sprintf('Calling %s() without a prefix is deprecated.', __METHOD__), E_USER_DEPRECATED);
$prefix = Factory::getApplication()->getName();
}
$className = $this->getClassName('Table\\' . ucfirst($name) . 'Table', $prefix) ?: $this->getClassName('Table\\' . ucfirst($name) . 'Table', 'Administrator');
if (!$className) {
return null;
}
if (\array_key_exists('dbo', $config)) {
$db = $config['dbo'];
} else {
$db = Factory::getDbo();
}
return new $className($db);
}