[drupal-devel] multidimensional arrays VS objects. should we go for
berdrupal at tiscali.be
Mon Oct 10 11:01:23 UTC 2005
When designing the patch for hook_links to return structured data, instead of
that accursed string, I found that we have no "good practice" nor consistency
in core when to use objects and when to use keyed arrays.
So, Is it an idea to discuss this at druopalCON, to discuss this here? Or does
it not really matter to others?
I would prefer to have One Method.
using structured arrays would mean converting all(!) $node->foo (and the
likes) stuff to $node['foo']. While using the other one would probably mean
changing all (haha) form api stuff to objects, but certainly all menu items.
I think it is doable like it is now, but that it is just Not Very Clean. (and
will result in problems, like we had for php5)
IMO the clean way is to have arrays when the data is NOT structured, but is a
list of similar items, but to have objects when it is structured.
so $menu_item->path instead of $menu_item['path']. just like we have for most
'things' like nodes, comments, terms, etc. But all these $menu_items should
sit in a $items array, not in $items->item1, $items->item2.
Most of this is in place already, but not all. Keeping Drupal clean means
deciding on standards like these too, IMO.
And oh, I am not saying that we should rewrite all this immediately, but
enforcing such guidelines/standards form now on will make sure we don not
introduce more inconsistancy.
More information about the drupal-devel