summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Negyesi2011-10-22 04:02:20 (GMT)
committer Karoly Negyesi2011-10-22 04:02:20 (GMT)
commit94a333b7d01fadbad26a52b21ae2dd1221ab15bd (patch)
tree546dbd7d8c49096601e7c9c1d5d1954b2c6a835b
parent940cba4ec4ce40663fb4f6b641f53102a42872f3 (diff)
Field items apparently need to be arrays. Fixes #1133188.
-rw-r--r--relation_dummy_field/relation_dummy_field.module17
1 files changed, 11 insertions, 6 deletions
diff --git a/relation_dummy_field/relation_dummy_field.module b/relation_dummy_field/relation_dummy_field.module
index d389bee..fc023f8 100644
--- a/relation_dummy_field/relation_dummy_field.module
+++ b/relation_dummy_field/relation_dummy_field.module
@@ -104,7 +104,8 @@ function relation_dummy_field_field_formatter_view($entity_type, $entity, $field
case 'relation_otherendpoint':
foreach ($items as $delta => $item) {
$links = array();
- foreach (array_filter($item->endpoints[LANGUAGE_NONE]) as $endpoint) {
+ $relation = (object) $item;
+ foreach (array_filter($relation->endpoints[LANGUAGE_NONE]) as $endpoint) {
$related_entities = entity_load($endpoint['entity_type'], array($endpoint['entity_id']));
$related_entity = reset($related_entities);
if ($endpoint['entity_type'] == $entity_type && $endpoint['entity_id'] == $entity_id) {
@@ -120,8 +121,8 @@ function relation_dummy_field_field_formatter_view($entity_type, $entity, $field
$link['title'] = entity_label($endpoint['entity_type'], $related_entity);
$links[] = $link;
}
- $uri = entity_uri('relation', $item);
- $relation_link = l(t('Relation @rid', array('@rid' => $item->rid)), $uri['path'], $uri['options']);
+ $uri = entity_uri('relation', $relation);
+ $relation_link = l(t('Relation @rid', array('@rid' => $relation->rid)), $uri['path'], $uri['options']);
// Can't use #heading as it's mercilessly check_plain'd.
$element[$delta]['relation']['heading']['#markup'] = t('<h4>Part of !link</h4>', array('!link' => $relation_link));
$element[$delta]['relation']['heading']['#access'] = $display['type'] == 'relation_default';
@@ -136,7 +137,8 @@ function relation_dummy_field_field_formatter_view($entity_type, $entity, $field
$sentences = array();
foreach ($items as $delta => $item) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
- $relation_type = relation_type_load($item->relation_type);
+ $relation = (object) $item;
+ $relation_type = relation_type_load($relation->relation_type);
$subject = entity_label($entity_type, $entity) . ' '; // Subject of the sentence.
$count = 0; // For comma separation of objects.
@@ -145,7 +147,7 @@ function relation_dummy_field_field_formatter_view($entity_type, $entity, $field
// Gramatical predicate of teh sentence.
$predicate = $relation_type->directional ? $relation_type->reverse_label : $relation_type->label;
- foreach ($item->endpoints[LANGUAGE_NONE] as $endpoint) {
+ foreach ($relation->endpoints[LANGUAGE_NONE] as $endpoint) {
// Add all entities that aren't this entity to the sentence $objects.
// Check for duplicates of the $subject first.
if ($endpoint['entity_type'] == $entity_type && $endpoint['entity_id'] == $id && $duplicate == FALSE) {
@@ -190,6 +192,9 @@ function relation_dummy_field_field_prepare_view($entity_type, $entities, $field
}
$relation_ids = array_keys($query->execute());
// Who knows why but field does not like if the delta does not start at 0...
- $items[$id] = $relation_ids ? array_values(entity_load('relation', $relation_ids)) : array();
+ $items[$id] = array();
+ foreach (entity_load('relation', $relation_ids) as $relation) {
+ $items[$id][] = (array) $relation;
+ }
}
}