Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Edit.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
10 
12 {
16  const ID_MODE = 'id';
17  const PRODUCT_MODE = 'product';
18  const CATEGORY_MODE = 'category';
19  const CMS_PAGE_MODE = 'cms_page';
27  protected function _getMode()
28  {
29  if ($this->_getProduct()->getId() || $this->getRequest()->has('product')) {
31  } elseif ($this->_getCategory()->getId() || $this->getRequest()->has('category')) {
33  } elseif ($this->_getCmsPage()->getId() || $this->getRequest()->has('cms_page')) {
35  } elseif ($this->getRequest()->has('id')) {
37  } else {
38  $mode = $this->_objectManager->get(\Magento\UrlRewrite\Block\Selector::class)->getDefaultMode();
39  }
40  return $mode;
41  }
42 
48  public function execute()
49  {
50  $this->_view->loadLayout();
51  $this->_setActiveMenu('Magento_UrlRewrite::urlrewrite');
52 
53  $mode = $this->_getMode();
54  switch ($mode) {
55  case self::PRODUCT_MODE:
56  $editBlock = $this->_view->getLayout()->createBlock(
57  \Magento\UrlRewrite\Block\Catalog\Product\Edit::class,
58  '',
59  [
60  'data' => [
61  'category' => $this->_getCategory(),
62  'product' => $this->_getProduct(),
63  'is_category_mode' => $this->getRequest()->has('category'),
64  'url_rewrite' => $this->_getUrlRewrite(),
65  ]
66  ]
67  );
68  break;
70  $editBlock = $this->_view->getLayout()->createBlock(
71  \Magento\UrlRewrite\Block\Catalog\Category\Edit::class,
72  '',
73  [
74  'data' => ['category' => $this->_getCategory(), 'url_rewrite' => $this->_getUrlRewrite()]
75  ]
76  );
77  break;
79  $editBlock = $this->_view->getLayout()->createBlock(
80  \Magento\UrlRewrite\Block\Cms\Page\Edit::class,
81  '',
82  [
83  'data' => ['cms_page' => $this->_getCmsPage(), 'url_rewrite' => $this->_getUrlRewrite()]
84  ]
85  );
86  break;
87  case self::ID_MODE:
88  default:
89  $editBlock = $this->_view->getLayout()->createBlock(
90  \Magento\UrlRewrite\Block\Edit::class,
91  '',
92  ['data' => ['url_rewrite' => $this->_getUrlRewrite()]]
93  );
94  break;
95  }
96  $this->_view->getPage()->getConfig()->getTitle()->prepend($editBlock->getHeaderText());
97  $this->_addContent($editBlock);
98  $this->_view->renderLayout();
99  }
100 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$editBlock
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
_addContent(\Magento\Framework\View\Element\AbstractBlock $block)