? Pending

User tests: Successful: Unsuccessful:

avatar nikosdion
nikosdion
25 Aug 2022

Pull Request for Issue #38555 .

Summary of Changes

  • Adds setMVCFactory and getMVCFactory public methods to the BaseController
  • Adds a new \Joomla\CMS\MVC\Factory\MVCFactoryWrapper class for wrapping the MVCFactory service to extend it.

Testing Instructions

  1. Without the patch: Install the component https://github.com/nikosdion/com_example/commit/06f43fde850b79673500697e41c4945602fa34152.

  2. With the patch: Install the component https://github.com/nikosdion/com_example/commit/4413a9a399e0634cc7d37967188210a8185cc35d

Actual result BEFORE applying this Pull Request

You get an error.

That's because the custom MVCFactoryWrapper of the component cannot force itself as the MVCFactory service of the Controller. As a result, when the Controller calls its getModel or getView methods it uses the undecorated MVCFactory object which, of course, is blissfully unaware of our custom service. Therefore the Model which wants to use this service breaks.

Expected result AFTER applying this Pull Request

It works!

Our custom MVCFactoryWrapper extends from \Joomla\CMS\MVC\Factory\MVCFactoryWrapper which means that the created Controller and Model objects use our decorated wrapper as their MVCFactory instead of the undecorated service. Our decorated wrapper is aware of our custom service, therefore it can push it to the created models, even if they are created through the Controller's createModel method.

Documentation Changes Required

I will be documenting that in the developer's docs as there is currently nothing of the sort.

avatar nikosdion nikosdion - open - 25 Aug 2022
avatar nikosdion nikosdion - change - 25 Aug 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2022
Category Libraries
avatar nikosdion nikosdion - change - 25 Aug 2022
Labels Added: ?
avatar laoneo
laoneo - comment - 26 Aug 2022

Would be good to find an usage for this pr in the core, that extension devs would see how this can actually be used. But I couldn't find one.

avatar nikosdion
nikosdion - comment - 26 Aug 2022

The core components are one trick ponies. That's why it being practically impossible (unless you forked a big ol' chunk of code) to push custom services to models was not caught until I started writing documentation.

That's why I insist on writing documentation for the code I write. Trying to teach someone else how what I wrote works usually leads to identifying problems I couldn't think of when I was focused on the code in front of me. The guys writing Rector said pretty much the same. When they started writing the book on Rector they figured out problems they had never thought of and updated Rector.

avatar nikosdion nikosdion - change - 7 Dec 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-12-07 12:24:44
Closed_By nikosdion
avatar nikosdion nikosdion - close - 7 Dec 2022
avatar nikosdion nikosdion - change - 7 Dec 2022
Status Closed New
Closed_Date 2022-12-07 12:24:44
Closed_By nikosdion
avatar nikosdion nikosdion - change - 7 Dec 2022
Status New Pending
avatar nikosdion nikosdion - reopen - 7 Dec 2022
avatar nikosdion
nikosdion - comment - 8 Dec 2022

I am not going to be contributing to this project anymore. I won't be replying to any questions or making any changes until then. I will close any outstanding PRs and delete their code on December 31st, 2022. Merge whatever you want until then.

avatar nikosdion
nikosdion - comment - 5 Mar 2023

I tried to fix an obvious architectural issue, nobody cared. Oh, well, you can't say I didn't try. I'm closing this PR.

avatar nikosdion nikosdion - change - 5 Mar 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-03-05 17:26:57
Closed_By nikosdion
avatar nikosdion nikosdion - close - 5 Mar 2023

Add a Comment

Login with GitHub to post a comment