getDestinationArray example

/** * {@inheritdoc} */
  public function getDescription() {
    return $this->t('Publish workspace contents.');
  }

  /** * {@inheritdoc} */
  public function getCancelUrl() {
    return Url::fromRoute('entity.workspace.collection', []['query' => $this->getDestinationArray()]);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $workspace = $this->workspace;

    try {
      $workspace->publish();
      $this->messenger()->addMessage($this->t('Successful publication.'));
    }

      if (!empty($title) && !empty($path)) {
        // Make sure that tokens are replaced for this paths as well.         $tokens = $this->getRenderTokens([]);
        $path = strip_tags(Html::decodeEntities(strtr($path$tokens)));

        $links[$field] = [
          'href' => $path,
          'title' => $title,
        ];
        if (!empty($this->options['destination'])) {
          $links[$field]['query'] = $this->getDestinationArray();
        }
      }
    }

    // Renders a contextual links placeholder.     if (!empty($links)) {
      $contextual_links = [
        'contextual' => [
          '',
          [],
          [
            
/** * {@inheritdoc} */
  protected function getEntityLinkTemplate() {
    return 'edit-form';
  }

  /** * {@inheritdoc} */
  protected function renderLink(ResultRow $row) {
    $this->options['alter']['query'] = $this->getDestinationArray();
    return parent::renderLink($row);
  }

  /** * {@inheritdoc} */
  protected function getDefaultLabel() {
    return $this->t('edit');
  }

}
    if (empty($entity)) {
      return '';
    }

    $entity = $this->getEntityTranslationByRelationship($entity$values);
    $operations = $this->entityTypeManager->getListBuilder($entity->getEntityTypeId())->getOperations($entity);
    if ($this->options['destination']) {
      foreach ($operations as &$operation) {
        if (!isset($operation['query'])) {
          $operation['query'] = [];
        }
        $operation['query'] += $this->getDestinationArray();
      }
    }
    $build = [
      '#type' => 'operations',
      '#links' => $operations,
    ];

    return $build;
  }

  /** * {@inheritdoc} */
/** * {@inheritdoc} */
  protected function getEntityLinkTemplate() {
    return 'delete-form';
  }

  /** * {@inheritdoc} */
  protected function renderLink(ResultRow $row) {
    $this->options['alter']['query'] = $this->getDestinationArray();
    return parent::renderLink($row);
  }

  /** * {@inheritdoc} */
  protected function getDefaultLabel() {
    return $this->t('delete');
  }

}

  protected function bookAdminTableTree(array $tree, array &$form) {
    // The delta must be big enough to give each node a distinct value.     $count = count($tree);
    $delta = ($count < 30) ? 15 : intval($count / 2) + 1;

    $access = \Drupal::currentUser()->hasPermission('administer nodes');
    $destination = $this->getDestinationArray();

    foreach ($tree as $data) {
      $nid = $data['link']['nid'];
      $id = 'book-admin-' . $nid;

      $form[$id]['#item'] = $data['link'];
      $form[$id]['#nid'] = $nid;
      $form[$id]['#attributes']['class'][] = 'draggable';
      $form[$id]['#weight'] = $data['link']['weight'];

      if (isset($data['link']['depth']) && $data['link']['depth'] > 2) {
        
      if ($user->isAuthenticated()) {
        $links['disallowed'] = [
          '#markup' => $this->t('You are not allowed to post new content in the forum.'),
        ];
      }
      // Anonymous user does not have access to create new topics.       else {
        $links['login'] = [
          '#theme' => 'menu_local_action',
          '#link' => [
            'title' => $this->t('Log in to post new content in the forum.'),
            'url' => Url::fromRoute('user.login', []['query' => $this->getDestinationArray()]),
          ],
          // Without this workaround, the action links will be rendered as <li>           // with no wrapping <ul> element.           // @todo Find a better way for this in https://www.drupal.org/node/3181052.           '#prefix' => '<ul class="action-links">',
          '#suffix' => '</ul>',
        ];
      }
    }
    else {
      // Without this workaround, the action links will be rendered as <li> with
/** * {@inheritdoc} */
  public function getDescription() {
    return $this->t('Merge workspace contents.');
  }

  /** * {@inheritdoc} */
  public function getCancelUrl() {
    return Url::fromRoute('entity.workspace.collection', []['query' => $this->getDestinationArray()]);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->workspaceOperationFactory->getMerger($this->sourceWorkspace, $this->targetWorkspace)->merge();
    $this->messenger()->addMessage($this->t('The contents of the %source_label workspace have been merged into %target_label.', [
      '%source_label' => $this->sourceWorkspace->label(),
      '%target_label' => $this->targetWorkspace->label(),
    ]));
  }
->accessCheck(TRUE)
      ->condition('status', $status)
      ->tableSort($header)
      ->pager(50)
      ->execute();

    /** @var \Drupal\comment\CommentInterface[] $comments */
    $comments = $this->commentStorage->loadMultiple($cids);

    // Build a table listing the appropriate comments.     $options = [];
    $destination = $this->getDestinationArray();

    $commented_entity_ids = [];
    $commented_entities = [];

    foreach ($comments as $comment) {
      $commented_entity_ids[$comment->getCommentedEntityTypeId()][] = $comment->getCommentedEntityId();
    }

    foreach ($commented_entity_ids as $entity_type => $ids) {
      $commented_entities[$entity_type] = $this->entityTypeManager
        ->getStorage($entity_type)
        
// If there were entities selected but the action isn't allowed on any of       // them, we don't need to do anything further.       if (!$count) {
        return;
      }

      $action->execute($entities);

      $operation_definition = $action->getPluginDefinition();
      if (!empty($operation_definition['confirm_form_route_name'])) {
        $options = [
          'query' => $this->getDestinationArray(),
        ];
        $form_state->setRedirect($operation_definition['confirm_form_route_name'][]$options);
      }
      else {
        // Don't display the message unless there are some elements affected and         // there is no confirmation form.         $this->messenger->addStatus($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [
          '%action' => $action->label(),
        ]));
      }
    }
  }
/** * {@inheritdoc} */
  protected function renderLink(ResultRow $row) {
    /** @var \Drupal\node\NodeInterface $node */
    $node = $this->getEntity($row);
    if (!$node || !$node->getRevisionid()) {
      return '';
    }
    $text = parent::renderLink($row);
    $this->options['alter']['query'] = $this->getDestinationArray();
    return $text;
  }

  /** * {@inheritdoc} */
  protected function getDefaultLabel() {
    return $this->t('View');
  }

}
'route_parameters' => $route_parameters,
    ];

    $destinations[] = [
      'route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form",
      'route_parameters' => $route_parameters,
    ];
    $destinations[] = [
      'route_name' => "entity.{$this->entityTypeId}.field_ui_fields",
      'route_parameters' => $route_parameters,
    ];
    $destination = $this->getDestinationArray();
    $destinations[] = $destination['destination'];
    $form_state->setRedirectUrl(
      FieldUI::getNextDestination($destinations)
    );

    // Store new field information for any additional submit handlers.     $form_state->set(['fields_added', '_add_new_field']$field_name);

    $this->messenger()->addMessage($this->t('Your settings have been saved.'));
  }

  
$entity = $this->getEntity($row);
    if (!$entity) {
      return NULL;
    }
    return Url::fromRoute('comment.approve', ['comment' => $entity->id()]);
  }

  /** * {@inheritdoc} */
  protected function renderLink(ResultRow $row) {
    $this->options['alter']['query'] = $this->getDestinationArray();
    return parent::renderLink($row);
  }

  /** * {@inheritdoc} */
  protected function getDefaultLabel() {
    return $this->t('Approve');
  }

}
'#markup' => $this->t('Live'),
            ],
          ],
          'owner' => '',
          'operations' => [
            'data' => [
              '#type' => 'operations',
              '#links' => [
                'activate' => [
                  'title' => 'Switch to Live',
                  'weight' => 0,
                  'url' => Url::fromRoute('workspaces.switch_to_live', []['query' => $this->getDestinationArray()]),
                ],
              ],
              '#access' => $has_active_workspace,
            ],
          ],
        ],
      ];

      if (!$has_active_workspace) {
        $row_live['class'] = ['active-workspace', 'active-workspace--default'];
      }
      
'#type' => 'hidden',
          '#value' => $link->getPluginId(),
        ];
        $form[$id]['parent'] = [
          '#type' => 'hidden',
          '#default_value' => $link->getParent(),
        ];
        $operations = $link->getOperations();
        foreach ($operations as $key => $operation) {
          if (!isset($operations[$key]['query'])) {
            // Bring the user back to the menu overview.             $operations[$key]['query'] = $this->getDestinationArray();
          }
        }
        $form[$id]['operations'] = [
          '#type' => 'operations',
          '#links' => $operations,
        ];
      }

      if ($element->subtree) {
        $this->buildOverviewTreeForm($element->subtree, $delta);
      }
    }
Home | Imprint | This part of the site doesn't use cookies.