Commit c9056323 authored by git's avatar git Committed by miro_dietiker

Issue #2704717 by yongt9412, Berdir: Remove special case on EntityFormatter for new entities

parent 4f86ca7c
......@@ -129,20 +129,13 @@ class EntityReferenceRevisionsEntityFormatter extends EntityReferenceRevisionsFo
$this->loggerFactory->get('entity')->error('Recursive rendering detected when rendering entity @entity_type @entity_id. Aborting rendering.', array('@entity_type' => $entity->getEntityTypeId(), '@entity_id' => $entity->id()));
return $elements;
}
$elements[$delta] = entity_view($entity, $view_mode, $entity->language()->getId());
if ($entity->id()) {
$elements[$delta] = entity_view($entity, $view_mode, $entity->language()->getId());
// Add a resource attribute to set the mapping property's value to the
// entity's url. Since we don't know what the markup of the entity will
// be, we shouldn't rely on it for structured data such as RDFa.
if (!empty($items[$delta]->_attributes)) {
$items[$delta]->_attributes += array('resource' => $entity->url());
}
}
else {
// This is an "auto_create" item.
$elements[$delta] = array('#markup' => $entity->label());
// Add a resource attribute to set the mapping property's value to the
// entity's url. Since we don't know what the markup of the entity will
// be, we shouldn't rely on it for structured data such as RDFa.
if (!empty($items[$delta]->_attributes) && !$entity->isNew() && $entity->hasLinkTemplate('canonical')) {
$items[$delta]->_attributes += array('resource' => $entity->toUrl()->toString());
}
$depth = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment