generateTypeList( 'media', 'media_type', 'entity.media.add_form', 'entity.media_type.add_form', $field, ['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 @field field.", [ '@field' => $field, ]), 'manage_link' => $manage_link, 'add_media' => $add_media_list, ]; } /** * Check if the object being displayed "is Islandora". * * @param \Drupal\Core\Routing\RouteMatch $route_match * The current routing match. * * @return \Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden * Whether we can or can't show the "thing". */ public function access(RouteMatch $route_match) { // Route match is being used as opposed to slugs as there are a few // admin routes being altered. // @see: \Drupal\islandora\EventSubscriber\AdminViewsRouteSubscriber::alterRoutes(). if ($route_match->getParameters()->has('node')) { $node = $route_match->getParameter('node'); if (!$node instanceof NodeInterface) { $node = Node::load($node); } // Ensure there's actually a node before referencing it. if ($node) { if ($this->utils->isIslandoraType($node->getEntityTypeId(), $node->bundle())) { return AccessResult::allowed(); } } } return AccessResult::forbidden(); } }