-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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] Check on the component if the categories support is available #20692
Conversation
if ($component instanceof AssociationServiceInterface) | ||
{ | ||
$assoc = $component->hasAssociationsCategorySupport(); | ||
return $assoc; |
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.
[CS] Add an empty line before the return
@@ -326,15 +327,22 @@ public function getAssoc() | |||
if (!$assoc || !$component || !$cname) | |||
{ | |||
$assoc = false; | |||
return $assoc; |
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.
[CS] Add an empty line before the return
@@ -1281,15 +1284,22 @@ public function getAssoc() | |||
if (!$assoc || !$component || !$cname) | |||
{ | |||
$assoc = false; | |||
return $assoc; |
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.
[CS] Add an empty line before the return
if ($component instanceof AssociationServiceInterface) | ||
{ | ||
$assoc = $component->hasAssociationsCategorySupport(); | ||
return $assoc; |
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.
[CS] Add an empty line before the return
I have tested this item ✅ successfully on b2f878b This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20692. |
@laoneo |
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function hasAssociationsCategorySupport() |
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.
Do you really need this method in the interface/trait? You can't just have code do the instanceof check without relying on an interface to be able to say you can do this instanceof check?
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.
If every component which has associations and categories integrated, does also have associations for the category automatically, then yes. Wasn't sure about 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.
I just don't get what the difference is in using $component instanceof CategoriesServiceInterface
versus $component->hasAssociationsCategorySupport()
is all. Like why does this has method need to be part of an interface? Unless you've got a plan for being able to dynamically toggle this support it just feels like adding an interface method for the sake of having 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.
Actually the component has control to decide if categories associations is supported, what the trait does is just to add default behavior. As I said if we can guarantee that when a component implements the AssociationsServiceInterface and Categories that associations for categories is then also working for the component. Then I'm more that happy to remove it. I just don't know that detail. Perhaps @infograf768 can shed some light here.
Simple. That code path won't execute in the case of com_content because of the checks above it. So if a component follows the service architecture, it'll get what it needs from that and return. If it doesn't, then it'll try to locate the class and file the "old" way. |
What was done when was implemented com_associations was to make sure to define for each component its possible associations. For example for com_contacts in the If you look at com_menus similar file, you will see that category is not part of the code. For com_content you moved the file and changed the class: similar methods are present in My question above would have been more clear is I had asked why you decided to change the former structure for com_content ONLY as it was working perfectly OK and is still doing so for the other components. The |
BTW, patch works fine in admin everywhere where we display/edit categories. |
Yes, the strategy is to bring com_content into a state where we can say it is the way to go for all extensions and then I will convert the rest. Don't worry about different set ups between core components for now. |
As I said, if it is coded such in the component association helper, it will. Nothing is automatic. Not sure I understand what you exactly mean otherwise. |
I'm not talking about how it is implemented but more about the set up. Lats try it differently. Can a component has associations and categories but not associations support for categories? |
If it has, it means that it is wrongly coded. There is no reason to do so and I don't know of any. |
Because when I remove the check function now, it is not possible (or only with an effort which we can avoid now) to add it later when J4 is released. That's why I want to have confirmation on this. |
TBH: if someone coding a multingual aware component which uses categories does not add the necessary code to also associate categories, this coder should just be eliminated from the surface of the Earth by any means, even illegal ones. 😃 |
@laoneo |
Moved the helper function getAssociations to the extension helper class which is accessible through the service. This comes with the cost of a BC break. An alternative would be to introduce a new helper interface and a function in Additionally all of this must be set from the service provider down to the component class. Not sure if we want to go that way. What do you guys think? |
This still does not work for multilingual associations between content categories for example (I guess also articles).
We need $cassociations further down
|
I tested changing in mod_languages as well as languagefilter For example the display of a sub category I am rather expecting (as I have a hidden List All Categories menu item for each language with alias But I guess this is due to the "modern router" in 4.0 (as it does work fine in staging) |
Hard to say. I've only rewritten it for Joomla 4.0 alpha from last year and the release is from january. There were quite a lot of major changes to the repo since then. I'm not constantely adjusting it to the latest changes in architecture :) |
Try it with the j3 version as we should support them and we need to make sure these versions do work. Not one which is made for J4 alpha 1. |
The J3 version likely doesn't work as it uses various deprecated functions. |
@laoneo can you fix the conflicts with this one so I can merge it please? |
Merged upstream and fixed conflicts. |
I have tested this item ✅ successfully on 720f944 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20692. |
@wilsonge Can this be merged? |
I have tested this item ✅ successfully on 720f944 Please, again, @wilsonge , merge. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20692. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20692. |
Updated branch to allow merging. |
Restarting drone. |
@infograf768 i have no idea what that error is but its been there for a while - i did ask what it was but got no response |
Going to merge this one to move on with associations testing. Thanks to the testers. Please provide the routing patch in a new pr. |
Thanks @laoneo |
For legacy everything should work as before. We just extended it with services. |
I still get issues in back-end com_associations for com_contact for example (who has its associations class in a different file/location and with a different type of class name). Here I still get for single contact
Did not test but I guess it will be the same for newsfeeds. |
I suggest to solve this one before modifying these components to use services. |
Please open a new issue as I don't think it is related to services at all. |
Pull Request for Issue #20667.
Summary of Changes
Adds a check function if associations is available for categories of the current component.
Testing Instructions
Expected result
The Associations column should display.
Actual result
No Associations column is displayed.