Skip to content
Snippets Groups Projects
Commit 828232cb authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

ISAICP-9013: Ensure a solution stub for each new release.

parent 14b1ad7b
No related branches found
No related tags found
1 merge request!182Release v1.111.1
......@@ -15,6 +15,8 @@
use Drupal\Core\Session\AccountInterface;
use Drupal\joinup_release\Entity\ReleaseInterface;
use Drupal\rdf_entity\RdfInterface;
use Drupal\rdf_sync\RdfSyncMapper;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
......@@ -22,6 +24,17 @@
*/
class ReleaseController extends ControllerBase {
public function __construct(
protected readonly RdfSyncMapper $rdfSyncMapper,
) {}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container): self {
return new static($container->get('rdf_sync.mapper'));
}
/**
* Controller for the base form.
*
......@@ -171,10 +184,19 @@ public function overviewAccess(RdfInterface $rdf_entity, RouteMatchInterface $ro
* The unsaved release entity.
*/
protected function createNewRelease(RdfInterface $rdf_entity): ReleaseInterface {
// @todo Remove solution stub workaround in ISAICP-8572.
if (!$solution_stub = $this->rdfSyncMapper->getEntityByUri($rdf_entity->id())) {
$this->getLogger('php')->error("Solution {$rdf_entity->id()} lacks a solution stub.");
}
/** @var \Drupal\rdf_entity\RdfInterface $release */
return $this->entityTypeManager()->getStorage('node')->create([
'type' => 'release',
'og_audience' => $rdf_entity->id(),
'solution_data' => [
'target_id' => $solution_stub?->id(),
'target_revision_id' => $solution_stub?->getRevisionId(),
],
]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment