/** * Returns a build array for the solution releases overview page. * * @param \Drupal\rdf_entity\RdfInterface $rdf_entity * The solution rdf entity. * * @return array * The build array for the page. */ public function overview(RdfInterface $rdf_entity) { $view_builder = $this->entityTypeManager()->getViewBuilder('rdf_entity'); $ids = $this->queryFactory->get('rdf_entity', 'AND')->condition('rid', 'asset_release')->condition('field_isr_is_version_of', $rdf_entity->id())->sort('field_isr_creation_date', 'DESC')->execute(); $releases = []; /** @var \Drupal\rdf_entity\RdfInterface $release */ foreach (Rdf::loadMultiple($ids) as $release) { $releases[] = $view_builder->view($release, 'compact'); } return ['#theme' => 'asset_release_releases_download', '#releases' => $releases]; }
/** * {@inheritdoc} */ protected function processStubRow(Row $row) { parent::processStubRow($row); $stub_commented_entity_type = $row->getDestinationProperty('entity_type'); // While parent::getEntity() fills the bundle property for stub entities // if it's still empty, here we must also make sure entity_id/entity_type // are filled (so $comment->getCommentedEntity() always returns a value). if (empty($this->stubCommentedEntityIds[$stub_commented_entity_type])) { // Fill stub entity id. Any id will do, as long as it exists. $entity_type = $this->entityManager->getDefinition($stub_commented_entity_type); $id_key = $entity_type->getKey('id'); $result = $this->entityQuery->get($stub_commented_entity_type)->range(0, 1)->execute(); if ($result) { $this->stubCommentedEntityIds[$stub_commented_entity_type] = array_pop($result); $row->setSourceProperty($id_key, $this->stubCommentedEntityIds[$stub_commented_entity_type]); } else { throw new MigrateException(t('Could not find parent entity to use for comment %id', ['%id' => implode(':', $row->getSourceIdValues())]), MigrationInterface::MESSAGE_ERROR); } } $row->setDestinationProperty('entity_id', $this->stubCommentedEntityIds[$stub_commented_entity_type]); $row->setDestinationProperty('entity_type', $stub_commented_entity_type); $row->setDestinationProperty('created', REQUEST_TIME); $row->setDestinationProperty('changed', REQUEST_TIME); }