Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Drop the MVCFactoryFactory #22732

Merged
merged 3 commits into from
Oct 24, 2018

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Oct 19, 2018

Summary of Changes

In #20217 got an MVCFactoryFactoryInterface introduced to create an MVCFactoryInterface for a given application. This can be made simpler by providing the MVCFactoryInterface instances directly by the component.

This implies that creating a model, view or table from the factory needs a prefix. If this is not the case, a deprecated message is triggered and the application name of the current application is used. It simplifies the code and plugins can directly override the service to create the factory, instead of having a factory which creates factories.

The factory can be loaded now through:
$factory = $app->bootComponent('com_content')->getMVCFactory();

If you call the create functions without prefix, a deprecated message is triggered, so instead of
$factory->createModel('Articles');

you should call it with a prefix:
$factory->createModel('Articles', 'Administrator');

Testing Instructions

Browse around in the front end and back end.

Expected result

All is working.

Actual result

All is working.

Documentation Changes Required

Needs to be documented together with the rest of the namespacing and service provider changes.

@@ -113,6 +103,19 @@ public function createModel($name, $prefix = '', array $config = [])
$prefix = 'Administrator';
}

if (!$prefix)
{
@trigger_error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly are we deprecating here? Are we saying you always have to pass in the prefix when creating a mvc instance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The controller which is loading the models on an ordinary page request is taking care of that already. It is just when a module, etc. needs a model, then a prefix is expected.

@wilsonge wilsonge merged commit 1badb83 into joomla:4.0-dev Oct 24, 2018
@wilsonge wilsonge deleted the j4/mvc/drop/factory branch October 24, 2018 07:24
@wilsonge
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants