We should provide a generic loader that can be used in menu item definitions and can load any type of entities.

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB

It's an easy patch :)

bojanz’s picture

Status: Needs review » Reviewed & tested by the community

Just what the doctor ordered.

dave reid’s picture

Wouldn't you need to use 'load arguments' => array(1, 'myentity')?

fago’s picture

Status: Reviewed & tested by the community » Needs work

ad #3: I think the documented load arguments are fine.

@patch: Makes sense to me. However, we should also update the 'admin ui' provided with the entity API to make use of it. Thus, changing the default for 'menu wildcard' + updating the docs that ENTITY_TYPE_load() is not required any more should do it. (see entity.api.php).

+    if ($entities) {
+      return reset($entities);
+    }

I don't think we need this check, as reset() is fine with empty arrays and just returns FALSE.
Also, why do we need to catch exceptions here? Usually we don't do so?

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new3.09 KB

Here you go.

entity_object_load() could also be a wrapper around entity_load_single(), once #1027908: entity_load() should return entities keyed by ID, not name lands.

fago’s picture

Status: Needs review » Fixed

thanks, committed.

dave reid’s picture

Hrm, the load arguments still look wrong. According to the example, 'myentity' is going to be passed in as the entity_id and there is no value for the entity_type parameter.

damien tournoud’s picture

'load arguments' is for additional arguments. The path part of the placeholder is always passed as the first argument.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.