ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPRGMessagePrinter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
28 protected ilLanguage $lng;
30
31 public function __construct(
35 ) {
36 $this->collection = $collection;
37 $this->lng = $lng;
38 $this->tpl = $tpl;
39 }
40
41 public function getMessageCollection(string $topic): ilPRGMessageCollection
42 {
43 return $this->collection->withNewTopic($topic);
44 }
45
46 public function showMessages(ilPRGMessageCollection $msg): void
47 {
48 if ($msg->hasSuccess()) {
49 $out = sprintf(
50 $this->lng->txt($msg->getDescription()),
51 count($msg->getSuccess())
52 );
53 $this->tpl->setOnScreenMessage("success", $out, true);
54 }
55
56 if ($msg->hasErrors()) {
57 $errmsg = [];
58 foreach ($msg->getErrors() as $err) {
59 [$message, $rec_indentifier] = $err;
60 $errmsg[] = sprintf('<li>%s (%s)</li>', $rec_indentifier, $this->lng->txt($message));
61 }
62
63 $out = sprintf(
64 $this->lng->txt($msg->getDescription() . '_failed'),
65 count($errmsg)
66 )
67 . '<ul>' . implode('', $errmsg) . '</ul>';
68
69 $this->tpl->setOnScreenMessage("failure", $out, true);
70 }
71 }
72}
$out
Definition: buildRTE.php:24
language handling
Holds information about multi-actions, mainly in context of member-assignemnts and status changes.
withNewTopic(string $description)
Util around ilPRGMessageCollection factors and output collections.
ilPRGMessageCollection $collection
getMessageCollection(string $topic)
__construct(ilPRGMessageCollection $collection, ilLanguage $lng, ilGlobalTemplateInterface $tpl)
showMessages(ilPRGMessageCollection $msg)
ilGlobalTemplateInterface $tpl
$message
Definition: xapiexit.php:31