ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
9 
20 function base()
21 {
22  global $DIC;
23  $factory = $DIC->ui()->factory();
24  $renderer = $DIC->ui()->renderer();
25  $df = new \ILIAS\Data\Factory();
26  $refinery = $DIC['refinery'];
27  $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
28  $url_builder = new URLBuilder($here_uri);
29  $example_namespace = ['prompt', 'close'];
30  list($url_builder, $action_token) = $url_builder->acquireParameters(
31  $example_namespace,
32  "action"
33  );
34 
35  //the endpoint; act according to parameter
36  $query = $DIC->http()->wrapper()->query();
37  if ($query->has($action_token->getName())) {
38  $action = $query->retrieve($action_token->getName(), $refinery->kindlyTo()->string());
39  if ($action === 'closecommand') {
40  //a state to simply close the modal
41  $response = $factory->prompt()->state()->close();
42  } else {
43  //The messagebox we are going to wrap into the prompt
44  $close = $factory->link()->standard(
45  'send close command',
46  $url_builder->withParameter($action_token, 'closecommand')->buildURI()->__toString()
47  );
48 
49  $message = $factory->messageBox()->info('some message box')
50  ->withLinks([$close]);
51  $response = $factory->prompt()->state()->show($message);
52  }
53  echo($renderer->renderAsync($response));
54  exit();
55  }
56 
57  //render prompt and button
58  $prompt = $factory->prompt()->standard($url_builder->buildURI());
59  return $renderer->render([
60  $factory->button()->standard('Show Prompt', $prompt->getShowSignal()),
61  $prompt
62  ]);
63 
64 }
base()
description: > The example demonstrates how to use commands in the Response.
Definition: base.php:20
$renderer
$response
Definition: xapitoken.php:90
global $DIC
Definition: shib_login.php:25
URLBuilder.
Definition: URLBuilder.php:39