Critical.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Critical messages collection
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\AdminNotification\Model\ResourceModel\Inbox\Collection;
  9. /**
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Critical extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  14. {
  15. /**
  16. * Resource collection initialization
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_init(
  23. \Magento\AdminNotification\Model\Inbox::class,
  24. \Magento\AdminNotification\Model\ResourceModel\Inbox::class
  25. );
  26. }
  27. /**
  28. * @return $this
  29. */
  30. protected function _initSelect()
  31. {
  32. parent::_initSelect();
  33. $this->addOrder(
  34. 'notification_id',
  35. self::SORT_ORDER_DESC
  36. )->addFieldToFilter(
  37. 'is_read',
  38. ['neq' => 1]
  39. )->addFieldToFilter(
  40. 'is_remove',
  41. ['neq' => 1]
  42. )->addFieldToFilter(
  43. 'severity',
  44. \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL
  45. )->setPageSize(
  46. 1
  47. );
  48. return $this;
  49. }
  50. }