Commit 184a8bd2 authored by sutharsan's avatar sutharsan Committed by Ra Mänd
Browse files

Issue #2701809 by cutesquirrel, Sutharsan, svenryen, spotzero: update...

Issue #2701809 by cutesquirrel, Sutharsan, svenryen, spotzero: update collection on a translatable node (i18n)
parent fd84c990
......@@ -220,7 +220,7 @@ class FieldCollectionItemEntity extends Entity {
* The entity type of the entity the field collection is attached to.
*/
public function updateHostEntity($entity, $host_entity_type = NULL) {
$this->fetchHostDetails();
$this->fetchHostDetails($entity);
// If it isn't possible to retrieve hostEntityType due to the fact that it's
// not saved in the DB yet then fill in info about the hostEntity manually.
// This happens when creating a new revision of a field collection entity
......@@ -300,13 +300,28 @@ class FieldCollectionItemEntity extends Entity {
}
}
protected function fetchHostDetails() {
/**
* Collects info about the field collection's host.
*
* @param $hostEntity
* The host entity object. (optional)
*/
protected function fetchHostDetails($hostEntity = NULL) {
if (!isset($this->hostEntityId) || (!$this->hostEntityId && $this->hostEntityRevisionId)) {
if ($this->item_id) {
// For saved field collections, query the field data to determine the
// right host entity.
$query = new EntityFieldQuery();
$query->fieldCondition($this->fieldInfo(), 'revision_id', $this->revision_id);
$field_info = $this->fieldInfo();
$query->fieldCondition($field_info, 'revision_id', $this->revision_id);
if ($hostEntity) {
$entity_type = key($field_info['bundles']);
$bundle = current($field_info['bundles'][$entity_type]);
$query->entityCondition('entity_type', $entity_type);
$query->entityCondition('entity_id', $hostEntity->nid);
$query->entityCondition('bundle', $bundle);
$query->propertyCondition('language', $hostEntity->language);
}
$query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
if (!$this->isInUse()) {
$query->age(FIELD_LOAD_REVISION);
......
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