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
Create a value object for a component record #14044
Conversation
libraries/cms/component/record.php
Outdated
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class JComponentRecord extends JObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this needs to extend JObject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erred heavily on the side of caution since right now it's a stdClass object. Much of the same reasoning why the new JMenuItem
does the same. The intent is in 4.0 to remove this.
If it's not needed I can drop it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I can buy it. In that case can we please add a @note
in to reflect we are going to drop JObject
property in J4 then please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do the same for XTD_buttons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgt41 Make your own PR 😛
FWIW I think we should make more liberal use of value objects versus untyped |
libraries/cms/component/record.php
Outdated
/** | ||
* Class constructor | ||
* | ||
* @param array $data The menu item data to load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look like copy/paste comment from somewhere. Should be The component record data to load or something like that
I have tested this item ✅ successfully on 53a260f
|
I have tested this item ✅ successfully on ff7e2c0 Don't tested lazy load cause don't know how. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14044. |
RTC as there are 2 successfully Tests? |
I have tested this item ✅ successfully on ff7e2c0 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14044. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14044. |
Agreed on the concept, but because JObject is deprecated in 4.0, why we are doing it? Or will you remove the extension of JObject in 4.0 and keep the value object? |
The extension of JObject is just to be extremely safe about it (we're converting from a |
ok, so I got the idea |
Summary of Changes
Create a new
JComponentRecord
value object representing the object loaded byJComponentHelper::load()
for a component. Shift the logic for converting the record's parameters to aRegistry
object to the point where the parameters are first accessed (this removes a needless conversion if callingJComponentHelper::isEnabled()
and that is the only interaction with a component's record).The value object extends
JObject
as a bridge to help with the transition. At 4.0, this class extension should be dropped as well as the magic getter/setter methods.Testing Instructions
The CMS still functions as intended. Component parameters are lazy loaded when needed.
Documentation Changes Required
Document the new class and scheduled deprecations.