entityTypeManager = $entity_type_manager; $this->renderer = $renderer; $this->currentUser = $current_user; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager'), $container->get('renderer'), $container->get('current_user') ); } /** * {@inheritdoc} */ public function clickSortable() { return FALSE; } /** * {@inheritdoc} */ public function render(ResultRow $values) { $links = []; $query = [ 'query' => [ 'source' => ltrim($this->getValue($values, 'path'), '/'), 'language' => $this->getValue($values, 'langcode'), 'destination' => $this->view->getPath(), ], ]; $links['add'] = [ 'title' => $this->t('Add redirect'), 'url' => Url::fromRoute('redirect.add', [], $query), ]; if ($this->currentUser->hasPermission('administer redirect settings')) { $links['ignore'] = [ 'title' => $this->t('Ignore'), 'url' => Url::fromRoute('redirect_404.ignore_404', [ 'path' => $this->getValue($values, 'path'), 'langcode' => $this->getValue($values, 'langcode'), ]), ]; } $operations['data'] = [ '#type' => 'operations', '#links' => $links, ]; return $this->renderer->render($operations); } /** * {@inheritdoc} */ public function access(AccountInterface $account) { return $this->entityTypeManager->getAccessControlHandler('redirect')->createAccess(); } }