NotifierPool.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Notification;
  7. /**
  8. * Default notifiers. Iterates through all registered notifiers to process message
  9. *
  10. * Class NotifierPool
  11. */
  12. class NotifierPool implements NotifierInterface
  13. {
  14. /**
  15. * @var NotifierList
  16. */
  17. protected $notifierList;
  18. /**
  19. * @param NotifierList $notifierList
  20. */
  21. public function __construct(NotifierList $notifierList)
  22. {
  23. $this->notifierList = $notifierList;
  24. }
  25. /**
  26. * Add new message
  27. *
  28. * @param int $severity
  29. * @param string $title
  30. * @param string|string[] $description
  31. * @param string $url
  32. * @param bool $isInternal
  33. * @throws \Magento\Framework\Exception\LocalizedException
  34. * @return $this
  35. */
  36. public function add($severity, $title, $description, $url = '', $isInternal = true)
  37. {
  38. foreach ($this->notifierList->asArray() as $notifier) {
  39. $notifier->add($severity, $title, $description, $url, $isInternal);
  40. }
  41. return $this;
  42. }
  43. /**
  44. * Add critical severity message
  45. *
  46. * @param string $title
  47. * @param string|string[] $description
  48. * @param string $url
  49. * @param bool $isInternal
  50. * @return $this
  51. */
  52. public function addCritical($title, $description, $url = '', $isInternal = true)
  53. {
  54. foreach ($this->notifierList->asArray() as $notifier) {
  55. $notifier->addCritical($title, $description, $url, $isInternal);
  56. }
  57. return $this;
  58. }
  59. /**
  60. * Add major severity message
  61. *
  62. * @param string $title
  63. * @param string|string[] $description
  64. * @param string $url
  65. * @param bool $isInternal
  66. * @return $this
  67. */
  68. public function addMajor($title, $description, $url = '', $isInternal = true)
  69. {
  70. foreach ($this->notifierList->asArray() as $notifier) {
  71. $notifier->addMajor($title, $description, $url, $isInternal);
  72. }
  73. return $this;
  74. }
  75. /**
  76. * Add minor severity message
  77. *
  78. * @param string $title
  79. * @param string|string[] $description
  80. * @param string $url
  81. * @param bool $isInternal
  82. * @return $this
  83. */
  84. public function addMinor($title, $description, $url = '', $isInternal = true)
  85. {
  86. foreach ($this->notifierList->asArray() as $notifier) {
  87. $notifier->addMinor($title, $description, $url, $isInternal);
  88. }
  89. return $this;
  90. }
  91. /**
  92. * Add notice
  93. *
  94. * @param string $title
  95. * @param string|string[] $description
  96. * @param string $url
  97. * @param bool $isInternal
  98. * @return $this
  99. */
  100. public function addNotice($title, $description, $url = '', $isInternal = true)
  101. {
  102. foreach ($this->notifierList->asArray() as $notifier) {
  103. $notifier->addNotice($title, $description, $url, $isInternal);
  104. }
  105. return $this;
  106. }
  107. }