Browse Source

Detect access before showing manage links.

pull/908/head
Rosie Le Faive 2 years ago
parent
commit
386ba0ceb1
  1. 16
      src/Controller/ManageMediaController.php
  2. 16
      src/Controller/ManageMembersController.php

16
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;
/** /**
@ -34,13 +35,18 @@ class ManageMediaController extends ManageMembersController {
['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 [ return [
'#type' => 'markup', '#type' => 'markup',
'#markup' => $this->t("The following media types can be added because they have the <code>@field</code> field. <a href=@manage_media_page>Manage media types</a>.", '#markup' => $this->t("The following media types can be added because they have the <code>@field</code> field.", [
[ '@field' => $field,
'@field' => $field, ]),
'@manage_media_page' => '/admin/structure/media', 'manage_link' => $manage_link,
]),
'add_media' => $add_media_list, 'add_media' => $add_media_list,
]; ];
} }

16
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;
@ -98,13 +99,18 @@ class ManageMembersController extends EntityController {
['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 [ return [
'#type' => 'markup', '#type' => 'markup',
'#markup' => $this->t("The following content types can be added because they have the <code>@field</code> field. <a href=@manage_content_types>Manage content types</a>.", '#markup' => $this->t("The following content types can be added because they have the <code>@field</code> field.", [
[ '@field' => $field,
'@field' => $field, ]),
'@manage_content_types' => '/admin/structure/types', 'manage_link' => $manage_link,
]),
'add_node' => $add_node_list, 'add_node' => $add_node_list,
]; ];
} }

Loading…
Cancel
Save