We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Module Controller files similar to core?

Developer Preview

Brian Litzinger's avatar
Brian Litzinger
693 posts
9 years ago
Brian Litzinger's avatar Brian Litzinger

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?

       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
9 years ago
Pascal Kriete's avatar Pascal Kriete

Short answer is yes. Our discussion forum control panel would certainly benefit.

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
9 years ago
Brian Litzinger's avatar Brian Litzinger

Sweet. Thanks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.