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