public
__construct
(mixed $config = array(), \Joomla\CMS\MVC\Factory\MVCFactoryInterface $factory = null, ?\Joomla\CMS\Application\CMSApplication $app = null, ?\Joomla\Input\Input $input = null)
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The Application for the dispatcher
* @param Input $input Input
*
* @since 4.0.0
* @throws \Exception
*/
public function __construct($config = array(), MVCFactoryInterface $factory = null, ?CMSApplication $app = null, ?Input $input = null)
{
$this->modelState = new CMSObject();
parent::__construct($config, $factory, $app, $input);
// Guess the option as com_NameOfController
if (empty($this->option)) {
$this->option = ComponentHelper::getComponentName($this, $this->getName());
}
// Guess the \Text message prefix. Defaults to the option.
if (empty($this->text_prefix)) {
$this->text_prefix = strtoupper($this->option);
}
// Guess the context as the suffix, eg: OptionControllerContent.
if (empty($this->context)) {
$r = null;
if (!preg_match('/(.*)Controller(.*)/i', \get_class($this), $r)) {
throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500);
}
$this->context = str_replace('\\', '', strtolower($r[2]));
}
}