Skip to content

Commit

Permalink
AUCIR-138: Add default media redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
bibliophileaxe committed Jan 26, 2024
1 parent 89dcc9b commit 1c61785
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Form/FieldModelToMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@ public static function submit(array &$form, FormStateInterface $form_state) {
$mapped = static::getMapped($form_state);

if (!empty($mapped['media_type'])) {

switch ($mapped['media_type']) {
case 'media':
// If mapped to media, redirect to media upload page.
$form_state->setRedirect('entity.media.add_page');
// If mapped to media, redirect to node's media upload page.
$form_state->setRedirect('islandora.add_media_to_node_page', [
'node' => $form_state->getFormObject()->getEntity()->id(),
]);
break;

default:
Expand All @@ -178,6 +179,13 @@ public static function submit(array &$form, FormStateInterface $form_state) {
$form_state->getFormObject()->getEntity()->id()
);

// Set the 'published' flag.
NestedArray::setValue(
$query_params,
static::PUBLISHED_FLAG,
$form_state->getValue('status', 1)
);

// Make the media ingest select the "original use" term, by default.
$original_use_id = static::getOriginalUseId();
if ($original_use_id) {
Expand All @@ -188,13 +196,6 @@ public static function submit(array &$form, FormStateInterface $form_state) {
);
}

// Set the 'published' flag.
NestedArray::setValue(
$query_params,
static::PUBLISHED_FLAG,
$form_state->getValue('status', 1)
);

// Actually set the redirect.
$form_state->setRedirect('entity.media.add_form', [
'media_type' => $mapped['media_type'],
Expand Down

0 comments on commit 1c61785

Please sign in to comment.