Skip to content
Snippets Groups Projects
Unverified Commit 053d9bcc authored by Lee Rowlands's avatar Lee Rowlands Committed by Lee Rowlands
Browse files

Issue #3067304 by larowlan, megadesk3000, nanak: Try to access $parentField ....

Issue #3067304 by larowlan, megadesk3000, nanak: Try to access $parentField . '_weight' instead of $parentField . '__weight' in loadSiblingEntityWeights()
parent a593449a
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
namespace Drupal\entity_hierarchy\Plugin\Field\FieldType;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
......@@ -247,7 +248,8 @@ class EntityReferenceHierarchy extends EntityReferenceItem {
->groupBy($parentField . '.weight')
->condition($key, $ids, 'IN')
->execute();
$entities = array_combine(array_column($entities, $key), array_column($entities, $parentField . '_weight'));
$weightSeparator = $fieldDefinition instanceof BaseFieldDefinition ? '__' : '_';
$entities = array_combine(array_column($entities, $key), array_column($entities, $parentField . $weightSeparator. 'weight'));
foreach ($siblings as $node) {
if (!isset($entities[$node->getRevisionId()])) {
continue;
......
......@@ -5,12 +5,13 @@
* Contains main module functions.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Implements hook_entity_base_field_info().
*/
function entity_hierarchy_test_base_field_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
function entity_hierarchy_test_base_field_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'entity_test') {
return [
'parents' => BaseFieldDefinition::create('entity_reference_hierarchy')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment