Grid.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\UrlRewrite\Block\Cms\Page;
  7. /**
  8. * CMS pages grid for URL rewrites
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  12. */
  13. class Grid extends \Magento\Cms\Block\Adminhtml\Page\Grid
  14. {
  15. /**
  16. * Constructor
  17. *
  18. * @return void
  19. */
  20. public function _construct()
  21. {
  22. parent::_construct();
  23. $this->setUseAjax(true);
  24. }
  25. /**
  26. * Disable massaction
  27. *
  28. * @return $this
  29. */
  30. protected function _prepareMassaction()
  31. {
  32. return $this;
  33. }
  34. /**
  35. * Prepare columns layout
  36. *
  37. * @return $this
  38. */
  39. protected function _prepareColumns()
  40. {
  41. $this->addColumn('title', ['header' => __('Title'), 'align' => 'left', 'index' => 'title']);
  42. $this->addColumn('identifier', ['header' => __('URL Key'), 'align' => 'left', 'index' => 'identifier']);
  43. if (!$this->_storeManager->isSingleStoreMode()) {
  44. $this->addColumn(
  45. 'store_id',
  46. [
  47. 'header' => __('Store View'),
  48. 'index' => 'store_id',
  49. 'type' => 'store',
  50. 'store_all' => true,
  51. 'store_view' => true,
  52. 'sortable' => false,
  53. 'filter_condition_callback' => [$this, '_filterStoreCondition']
  54. ]
  55. );
  56. }
  57. $this->addColumn(
  58. 'is_active',
  59. [
  60. 'header' => __('Status'),
  61. 'index' => 'is_active',
  62. 'type' => 'options',
  63. 'options' => $this->_cmsPage->getAvailableStatuses()
  64. ]
  65. );
  66. return $this;
  67. }
  68. /**
  69. * Get URL for dispatching grid ajax requests
  70. *
  71. * @return string
  72. */
  73. public function getGridUrl()
  74. {
  75. return $this->getUrl('adminhtml/*/cmsPageGrid', ['_current' => true]);
  76. }
  77. /**
  78. * Return row url for js event handlers
  79. *
  80. * @param \Magento\Cms\Model\Page|\Magento\Framework\DataObject $row
  81. * @return string
  82. */
  83. public function getRowUrl($row)
  84. {
  85. return $this->getUrl('adminhtml/*/edit', ['cms_page' => $row->getId()]);
  86. }
  87. }