ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPRGMessagePrinter.php
Go to the documentation of this file.
1 <?php declare(strict_types = 1);
2 
8 {
12  protected $collection;
13 
17  protected $lng;
18 
19  public function __construct(
22  ) {
23  $this->collection = $collection;
24  $this->lng = $lng;
25  }
26 
27  public function getMessageCollection(string $topic) : ilPRGMessageCollection
28  {
29  return $this->collection->withNewTopic($topic);
30  }
31 
32  public function showMessages(ilPRGMessageCollection $msg)
33  {
34  if ($msg->hasSuccess()) {
35  $out = sprintf(
36  $this->lng->txt($msg->getDescription()),
37  count($msg->getSuccess())
38  );
39  \ilUtil::sendSuccess($out, true);
40  }
41 
42  if ($msg->hasErrors()) {
43  $errmsg = [];
44  foreach ($msg->getErrors() as $err) {
45  list($message, $rec_indentifier) = $err;
46  $errmsg[] = sprintf('<li>%s (%s)</li>', $rec_indentifier, $this->lng->txt($message));
47  }
48 
49  $out = sprintf(
50  $this->lng->txt($msg->getDescription() . '_failed'),
51  count($errmsg)
52  )
53  . '<ul>' . implode('', $errmsg) . '</ul>';
54 
55  ilUtil::sendInfo($out, true);
56  }
57  }
58 }
Util around ilPRGMessageCollection factors and output collections.
withNewTopic(string $description)
showMessages(ilPRGMessageCollection $msg)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getMessageCollection(string $topic)
$message
Definition: xapiexit.php:14
__construct(ilPRGMessageCollection $collection, ilLanguage $lng)
Holds information about multi-actions, mainly in context of member-assignemnts and status changes...