?
avatar venomdev
venomdev
9 Jan 2021

Problem identified

The way I name my controllers and models are {{ComponentName}}Controller{{ControllerName}} and {{ComponentName}}Model{{ModelName}} so something like FruitStoreControllerApples and FruitStoreModelApples.

What I've noticed is using getName() in the model returns Apples and getname() in the controller returns FruitStore, this means every controller returns FruitStore instead of the intended controller name.

here's the 2 lines in question

Controller:

if (!preg_match('/(.*)Controller/i', get_class($this), $r))

Model:

if (!preg_match('/Model(.*)/i', get_class($this), $r))

Proposed solution

I believe it's a simple regex fix

avatar venomdev venomdev - open - 9 Jan 2021
avatar joomla-cms-bot joomla-cms-bot - change - 9 Jan 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 9 Jan 2021
avatar chmst chmst - change - 9 Jan 2021
Labels Added: ?
avatar chmst chmst - labeled - 9 Jan 2021
avatar joomdonation
joomdonation - comment - 9 Jan 2021

Although the method is getName(), it is actually used to return name of the component. If you fix it, everything will be broken. See some of it usages and you will understand:

So better leave it as how it is for now.

avatar richard67 richard67 - change - 9 Jan 2021
Labels Removed: ?
avatar richard67 richard67 - unlabeled - 9 Jan 2021
avatar richard67 richard67 - edited - 9 Jan 2021
avatar richard67 richard67 - close - 9 Jan 2021
avatar richard67 richard67 - change - 9 Jan 2021
Status New Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2021-01-09 13:23:53
Closed_By richard67
avatar richard67
richard67 - comment - 9 Jan 2021

Closing as expected behaviour.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31934.

avatar venomdev
venomdev - comment - 9 Jan 2021

Thanks for the clarification, I've since used the model name for my needs.

Add a Comment

Login with GitHub to post a comment