- πΊπΈUnited States earlyburg Bflo
Symfony Framework:
public function getFieldCollectionByNid($nid, $bundle_type, $collection_name) { $field_collection = FALSE; $node = \Drupal::service('entity_type.manager')->getStorage('node')->load($nid); if ($node->bundle() == $bundle_type) { $field_collection = $node->get($collection_name); } return $field_collection; }
Iterate through the field collection thusly:
foreach ($field_collection as $field) { $item = \Drupal::service('entity_type.manager')->getStorage('field_collection_item')->load($field->target_id); }