/** * Returns the distributions that are part of a solution. * * @param \Drupal\rdf_entity\RdfInterface $solution * The solution rdf entity. * * @return \Drupal\rdf_entity\RdfInterface[] * An array of distributions related to the solution. */ public function getSolutionDistributions(RdfInterface $solution) { $group_content_ids = $this->membershipManager->getGroupContentIds($solution, ['rdf_entity']); if (empty($group_content_ids['rdf_entity'])) { return []; } /** @var array $group_content */ $group_content = $this->entityTypeManager->getStorage('rdf_entity')->loadMultiple($group_content_ids['rdf_entity']); /** @var RdfInterface[] $distributions */ $distributions = array_filter($group_content, function (RdfInterface $entity) { return $entity->bundle() === 'asset_distribution'; }); return $distributions; }
/** * {@inheritdoc} */ public function build() { if (empty($this->collection)) { throw new \Exception('The "Collection content" block can only be shown on collection pages.'); } $content_ids = $this->membershipManager->getGroupContentIds($this->collection); $list = array(); foreach ($content_ids as $entity_type => $ids) { $storage = $this->entityTypeManager->getStorage($entity_type); $entities = $storage->loadMultiple($ids); $children = []; foreach ($entities as $entity) { $children[] = array('#markup' => $entity->link()); } if ($children) { $list[] = array('#markup' => $storage->getEntityType()->getLabel(), 'children' => $children); } } $build = array('list' => ['#theme' => 'item_list', '#items' => $list, '#cache' => ['tags' => ['og_group_content:' . $this->collection->id()]]]); return $build; }