? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
22 Mar 2017

Summary of Changes

Models, Views and Tables should not being created in the Controller or models itself. Instead of a factory should do the job.

This PR adds a new Mvc factory where we can pass that into a controller or model where the can create their objects trough. Like that we are one step closer to a DI set up.

This should simplify the work of @joomdonation in #14809, #14810 and #14721.

Testing Instructions

Browse the back end.

Expected result

No error.

Actual result

No error.

Documentation Changes Required

avatar laoneo laoneo - open - 22 Mar 2017
avatar laoneo laoneo - change - 22 Mar 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 22 Mar 2017
Category Libraries
avatar laoneo laoneo - change - 22 Mar 2017
Labels Added: ?
8d03ae8 22 Mar 2017 avatar laoneo CS
avatar joomdonation
joomdonation - comment - 25 Mar 2017

I just looked at this implementation. With my limited architecture skill / experience, I could say it is right or wrong. However, I do have some questions below:

  1. How do you plan to make this compatible with Controller implement in 4.0-dev branch? In 4.0-dev, controller constructor has 3 parameters, $config, $app, $input. Will you pass $factory as the fourth parameter? So if you keep this implement for Joomla 3.8.x (only 2 parameters), then there would be conflict with 4.0?

Assume you pass $factory as the fourth parameter, $factory keep an instance of application, and we also has $app as parameter of controller parameter, so basically, there are 2 apps object passed to controller constructor, seems it doesn't right.

  1. About optional parameters in factory methods

Look at createModel method

public function createModel($name, $prefix = '', array $config = array())

Can $prefix really be an optional parameter? I think the only parameter should be optional is $config. If someone calls this method without proper $prefix parameter, it won't work as expected (the system could never create a model with only $name parameter)

In current legacy controller class, $prefix is marked as optional parameter because it is a protected method. The only way to actual get model in controller is via getModel method and that method does calculates default $prefix if needed before calling createModel method.

The same question is applied for createView, createTable methods.

  1. Is it logic that a MVC factory doesn't has method to create controller?
avatar laoneo
laoneo - comment - 27 Mar 2017
  1. This needs to be backported to 3.8. But yes it will become then the fourth argument.
  2. In legacy, the prefix is optional for JModel::getInstance, so I guess it is fine then.
  3. Creating the controller is done in the dispatcher.
avatar wilsonge
wilsonge - comment - 6 Apr 2017

Let's fix conflicts here. I think we probably do want to end up moving controller creation into the MVC factory too. but this is a good starting point.

avatar laoneo
laoneo - comment - 7 Apr 2017

@joomdonation is taking over the namespacing part so I'm out.

avatar laoneo laoneo - change - 7 Apr 2017
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2017-04-07 07:24:37
Closed_By laoneo
avatar laoneo laoneo - close - 7 Apr 2017
avatar laoneo laoneo - change - 7 Apr 2017
Status Closed New
Closed_Date 2017-04-07 07:24:37
Closed_By laoneo
avatar laoneo laoneo - change - 7 Apr 2017
Status New Pending
avatar laoneo laoneo - reopen - 7 Apr 2017
avatar wilsonge wilsonge - change - 7 Apr 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-04-07 14:02:32
Closed_By wilsonge
Labels Added: ?
Removed: ?
avatar wilsonge wilsonge - close - 7 Apr 2017
avatar wilsonge wilsonge - merge - 7 Apr 2017

Add a Comment

Login with GitHub to post a comment