You are here

public function ChannelFormController::tokens in Courier 8

Same name and namespace in other branches
  1. 2.x src/Controller/ChannelFormController.php \Drupal\courier\Controller\ChannelFormController::tokens()

Get tokens for a template collection.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

\Drupal\courier\TemplateCollectionInterface $courier_template_collection: A template collection entity.

Return value

\Drupal\Core\Ajax\AjaxResponse A AJAX response object.

1 string reference to 'ChannelFormController::tokens'
courier.routing.yml in ./courier.routing.yml
courier.routing.yml

File

src/Controller/ChannelFormController.php, line 70

Class

ChannelFormController
Controller for channels.

Namespace

Drupal\courier\Controller

Code

public function tokens(Request $request, TemplateCollectionInterface $courier_template_collection) {
  $template_collection = $courier_template_collection;
  $render['tokens'] = [
    '#type' => 'container',
  ];
  $render['tokens']['list'] = $this
    ->templateCollectionTokenElement($template_collection);
  if ($request->request
    ->get('js')) {
    $selector = '.template_collection[template_collection=' . $template_collection
      ->id() . '] .properties_container';
    $response = new AjaxResponse();
    $response
      ->addCommand(new HtmlCommand($selector, $render));
    return $response;
  }
  return $render;
}