AbstractDashboard.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Dashboard;
  7. use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
  8. /**
  9. * Adminhtml dashboard tab abstract
  10. *
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. */
  13. abstract class AbstractDashboard extends \Magento\Backend\Block\Widget
  14. {
  15. /**
  16. * @var \Magento\Backend\Helper\Dashboard\AbstractDashboard
  17. */
  18. protected $_dataHelper = null;
  19. /**
  20. * @var \Magento\Reports\Model\ResourceModel\Order\CollectionFactory
  21. */
  22. protected $_collectionFactory;
  23. /**
  24. * @param \Magento\Backend\Block\Template\Context $context
  25. * @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory
  26. * @param array $data
  27. */
  28. public function __construct(
  29. \Magento\Backend\Block\Template\Context $context,
  30. \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory,
  31. array $data = []
  32. ) {
  33. $this->_collectionFactory = $collectionFactory;
  34. parent::__construct($context, $data);
  35. }
  36. /**
  37. * @return array|AbstractCollection|\Magento\Eav\Model\Entity\Collection\Abstract
  38. */
  39. public function getCollection()
  40. {
  41. return $this->getDataHelper()->getCollection();
  42. }
  43. /**
  44. * @return int
  45. */
  46. public function getCount()
  47. {
  48. return $this->getDataHelper()->getCount();
  49. }
  50. /**
  51. * Get data helper
  52. *
  53. * @return \Magento\Backend\Helper\Dashboard\AbstractDashboard
  54. */
  55. public function getDataHelper()
  56. {
  57. return $this->_dataHelper;
  58. }
  59. /**
  60. * @return $this
  61. */
  62. protected function _prepareData()
  63. {
  64. return $this;
  65. }
  66. /**
  67. * @return $this
  68. */
  69. protected function _prepareLayout()
  70. {
  71. $this->_prepareData();
  72. return parent::_prepareLayout();
  73. }
  74. }