You are here

public function MenuExampleController::placeholderArgs in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/menu_example/src/Controller/MenuExampleController.php \Drupal\menu_example\Controller\MenuExampleController::placeholderArgs()

Demonstrates how you can provide a placeholder url arguments.

Throws

\InvalidArgumentException

See also

\Drupal\menu_example\Controller\MenuExampleController::placeholderArgsDisplay()

https://www.drupal.org/docs/8/api/routing-system/using-parameters-in-routes

1 string reference to 'MenuExampleController::placeholderArgs'
menu_example.routing.yml in menu_example/menu_example.routing.yml
menu_example/menu_example.routing.yml

File

menu_example/src/Controller/MenuExampleController.php, line 232

Class

MenuExampleController
Controller routines for menu example routes.

Namespace

Drupal\menu_example\Controller

Code

public function placeholderArgs() {
  $url = Url::fromRoute('examples.menu_example.placeholder_argument.display', [
    'arg' => 3343,
  ]);
  return [
    '#markup' => $this
      ->t('Demonstrate placeholders by visiting @link', [
      '@link' => Link::createFromRoute($url
        ->getInternalPath(), $url
        ->getRouteName(), $url
        ->getRouteParameters())
        ->toString(),
    ]),
  ];
}