Browse Source

Merge pull request #908 from rosiel/add-form-improvements-2

Add (media/child) form improvements 2
pull/922/head
Nigel Banks 2 years ago committed by GitHub
parent
commit
f780c69556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/Controller/ManageMediaController.php
  2. 19
      src/Controller/ManageMembersController.php

18
src/Controller/ManageMediaController.php

@ -6,6 +6,7 @@ use Drupal\islandora\IslandoraUtils;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Routing\RouteMatch;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\Core\Url;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
/** /**
@ -25,7 +26,7 @@ class ManageMediaController extends ManageMembersController {
public function addToNodePage(NodeInterface $node) { public function addToNodePage(NodeInterface $node) {
$field = IslandoraUtils::MEDIA_OF_FIELD; $field = IslandoraUtils::MEDIA_OF_FIELD;
return $this->generateTypeList( $add_media_list = $this->generateTypeList(
'media', 'media',
'media_type', 'media_type',
'entity.media.add_form', 'entity.media.add_form',
@ -33,6 +34,21 @@ class ManageMediaController extends ManageMembersController {
$field, $field,
['query' => ["edit[$field][widget][0][target_id]" => $node->id()]] ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]]
); );
$manage_link = Url::fromRoute('entity.media_type.collection')->toRenderArray();
$manage_link['#title'] = $this->t('Manage media types');
$manage_link['#type'] = 'link';
$manage_link['#prefix'] = ' ';
$manage_link['#suffix'] = '.';
return [
'#type' => 'markup',
'#markup' => $this->t("The following media types can be added because they have the <code>@field</code> field.", [
'@field' => $field,
]),
'manage_link' => $manage_link,
'add_media' => $add_media_list,
];
} }
/** /**

19
src/Controller/ManageMembersController.php

@ -7,6 +7,7 @@ use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Entity\Controller\EntityController; use Drupal\Core\Entity\Controller\EntityController;
use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Link; use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\islandora\IslandoraUtils; use Drupal\islandora\IslandoraUtils;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -88,7 +89,8 @@ class ManageMembersController extends EntityController {
*/ */
public function addToNodePage(NodeInterface $node) { public function addToNodePage(NodeInterface $node) {
$field = IslandoraUtils::MEMBER_OF_FIELD; $field = IslandoraUtils::MEMBER_OF_FIELD;
return $this->generateTypeList(
$add_node_list = $this->generateTypeList(
'node', 'node',
'node_type', 'node_type',
'node.add', 'node.add',
@ -96,6 +98,21 @@ class ManageMembersController extends EntityController {
$field, $field,
['query' => ["edit[$field][widget][0][target_id]" => $node->id()]] ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]]
); );
$manage_link = Url::fromRoute('entity.node_type.collection')->toRenderArray();
$manage_link['#title'] = $this->t('Manage content types');
$manage_link['#type'] = 'link';
$manage_link['#prefix'] = ' ';
$manage_link['#suffix'] = '.';
return [
'#type' => 'markup',
'#markup' => $this->t("The following content types can be added because they have the <code>@field</code> field.", [
'@field' => $field,
]),
'manage_link' => $manage_link,
'add_node' => $add_node_list,
];
} }
/** /**

Loading…
Cancel
Save