backdrop-contrib / entity_plus

This module wraps in a variety of additional entity-related functionality from various sources. Partial port of D7 Entity API.
https://backdropcms.org/project/entity_plus
GNU General Public License v2.0
3 stars 11 forks source link

Bring back current-page "language" properties #144

Closed argiepiano closed 1 year ago

argiepiano commented 1 year ago

The metadata properties for site:current_page were defined in locale.info.inc in D7. Those were removed from locale when it was ported as part of Backdrop's core.

Since locale is part of core and entity_plus is not, I believe it's best to add that property metadata information to Entity Plus' system.info.inc wrapped in an if statement to check whether locale is enabled. PR forthcoming.

argiepiano commented 1 year ago

BTW, the property should be renamed langcode to follow the pattern used in Backdrop.

argiepiano commented 1 year ago

And should add: these properties are used by the Rules translation module, which is being worked on currently.

argiepiano commented 1 year ago

Interestingly the getter callback for the property, as well as the option list callback already exist in Entity Plus! So, the only thing needed here is to just define the properties.

argiepiano commented 1 year ago

Actually the property CAN'T be renamed to langcode because the getter callback uses the property name (language) to obtain the global language object stored under the key language, by doing:

  return isset($GLOBALS[$name]) ? $GLOBALS[$name]->langcode : NULL;

So, if we name the property langcode, then the global language object is not found, as it is currently stored as $GLOBALS['language']

argiepiano commented 1 year ago

PR #145. @laryn, @hosef if you could review soon before we merge, that'd be great, so that we can fix the related stuff in Rules translation.

laryn commented 1 year ago

Makes sense and looks good to me on a readthrough. 👍

argiepiano commented 1 year ago

Thanks @laryn. @hosef, let me know if you want to review this one, as well as #146, which is also needed for Rules translation. Additionally I'll be submitting a PR for #67 tomorrow, which was started by @laryn some time ago.