You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When constructing arrays using DI (or also in layout XML) with the array type, it seems to be impossible to influence the order or the elements except via module load sequence.
However, it currently is not possible to have one module to add itself to the sequence of another module, which limits this option severely.
As I'm sure you are aware, the sort order of the array elements can be quite important.
In some instances, for example the RouterList, this problem is overcome by making each router in the list a sub-array with the possibility to add a sortOrder. This works fine, but if the injected array is one dimensional it isn't an option. It forces the structure onto the client receiving the array.
In other cases the injected list is simply an array of objects or strings, without the chance to influence the sort order.
One example is the composite phrase renderer. It isn't possible to add a renderer before the placeholder renderer.
It would be quite useful to be able to add an optional sortOrder attribute to the item node, which - if present - is used to sort the resulting array argument.
Maybe a before/after attribute (like in layout XML) would be more appropriate, but I'm sure opinions on this will vary. Personally I don't care, I would simply like to have an option to influence the sort order of dependency injected arrays built with in di.xml, without resorting to changing the module load sequence.
The text was updated successfully, but these errors were encountered:
Sorting wasn't implemented because it'll have impact on performance of ObjectManager. But I agree that we should support it. Thanks for the suggestion. I'll let you know when we have news about this.
When constructing arrays using DI (or also in layout XML) with the
array
type, it seems to be impossible to influence the order or the elements except via module load sequence.However, it currently is not possible to have one module to add itself to the sequence of another module, which limits this option severely.
As I'm sure you are aware, the sort order of the array elements can be quite important.
In some instances, for example the
RouterList
, this problem is overcome by making each router in the list a sub-array with the possibility to add asortOrder
. This works fine, but if the injected array is one dimensional it isn't an option. It forces the structure onto the client receiving the array.In other cases the injected list is simply an array of objects or strings, without the chance to influence the sort order.
One example is the composite phrase renderer. It isn't possible to add a renderer before the
placeholder
renderer.It would be quite useful to be able to add an optional
sortOrder
attribute to theitem
node, which - if present - is used to sort the resulting array argument.Maybe a before/after attribute (like in layout XML) would be more appropriate, but I'm sure opinions on this will vary. Personally I don't care, I would simply like to have an option to influence the sort order of dependency injected arrays built with in di.xml, without resorting to changing the module load sequence.
The text was updated successfully, but these errors were encountered: