While building out my settings pages I noticed that there doesn’t seem to be a way to make true Controller files in a module similar to how the pages are handled in core. E.g. The mcp file is a single “controller” and its wanting to call methods on that file for the actions. In an effort to move the bulk of the logic out of the mcp file I came up with the following in my mcp file:
public function index()
{
return $this->runController('index');
}
public function general() {
return $this->runController('general');
}
public function browser() {
return $this->runController('browser');
}
public function urlTranslations() {
return $this->runController('url-translations');
}
public function drafts() {
return $this->runController('drafts');
}
/**
* @param $page
* @return string
*/
public function runController($page)
{
$this->authorize();
$className = str_replace(' ', '', ucwords(str_replace('-', ' ', $page)));
$className = 'Publisher\\Controllers\\'.$className;
/** @var ControllerInterface $controller */
$controller = new $className();
return $controller->render($page);
}
I guess I’m wondering if there are plans to make mcp pages have more of a true MVC architecture?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.