MessageInterface.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Message;
  7. /**
  8. * Represent a message with a type, content text, and an isSticky attribute to prevent message from being cleared.
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. interface MessageInterface
  14. {
  15. /**
  16. * Default identifier
  17. */
  18. const DEFAULT_IDENTIFIER = 'default_message_identifier';
  19. /**
  20. * Error type
  21. */
  22. const TYPE_ERROR = 'error';
  23. /**
  24. * Warning type
  25. */
  26. const TYPE_WARNING = 'warning';
  27. /**
  28. * Notice type
  29. */
  30. const TYPE_NOTICE = 'notice';
  31. /**
  32. * Success type
  33. */
  34. const TYPE_SUCCESS = 'success';
  35. /**
  36. * Getter message type
  37. *
  38. * @return string
  39. */
  40. public function getType();
  41. /**
  42. * Getter for text of message
  43. *
  44. * @return string
  45. */
  46. public function getText();
  47. /**
  48. * Setter message text
  49. *
  50. * @param string $text
  51. * @return $this
  52. */
  53. public function setText($text);
  54. /**
  55. * Setter message identifier
  56. *
  57. * @param string $identifier
  58. * @return $this
  59. */
  60. public function setIdentifier($identifier);
  61. /**
  62. * Getter message identifier
  63. *
  64. * @return string
  65. */
  66. public function getIdentifier();
  67. /**
  68. * Setter for flag. Whether message is sticky
  69. *
  70. * @param bool $isSticky
  71. * @return $this
  72. */
  73. public function setIsSticky($isSticky);
  74. /**
  75. * Getter for flag. Whether message is sticky
  76. *
  77. * @return bool
  78. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  79. */
  80. public function getIsSticky();
  81. /**
  82. * Retrieve message as a string
  83. *
  84. * @return string
  85. */
  86. public function toString();
  87. /**
  88. * Sets message data
  89. *
  90. * @param array $data
  91. * @return $this
  92. * @throws \InvalidArgumentException
  93. */
  94. public function setData(array $data = []);
  95. /**
  96. * Returns message data
  97. *
  98. * @return array
  99. */
  100. public function getData();
  101. }