From 35e9144f8b9200eacf7a38783c590d28a724b290 Mon Sep 17 00:00:00 2001 From: Thomas Hauschild <7961978+Morgy93@users.noreply.github.com> Date: Tue, 31 Oct 2023 08:39:26 +0100 Subject: [PATCH] replace deprecated escaper --- .../Component/Listing/Column/BlockActions.php | 22 ++++------------ .../Component/Listing/Column/PageActions.php | 25 ++++++------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php index 098d00693ba21..2edb0e1caba55 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -40,16 +40,19 @@ class BlockActions extends Column * @param UrlInterface $urlBuilder * @param array $components * @param array $data + * @param Escaper|null $escaper */ public function __construct( ContextInterface $context, UiComponentFactory $uiComponentFactory, UrlInterface $urlBuilder, array $components = [], - array $data = [] + array $data = [], + ?Escaper $escaper = null ) { $this->urlBuilder = $urlBuilder; parent::__construct($context, $uiComponentFactory, $components, $data); + $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class); } /** @@ -60,7 +63,7 @@ public function prepareDataSource(array $dataSource) if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { if (isset($item['block_id'])) { - $title = $this->getEscaper()->escapeHtmlAttr($item['title']); + $title = $this->escaper->escapeHtmlAttr($item['title']); $item[$this->getData('name')] = [ 'edit' => [ 'href' => $this->urlBuilder->getUrl( @@ -92,19 +95,4 @@ public function prepareDataSource(array $dataSource) return $dataSource; } - - /** - * Get instance of escaper - * - * @return Escaper - * @deprecated 101.0.7 - */ - private function getEscaper() - { - if (!$this->escaper) { - // phpcs:ignore Magento2.PHP.AutogeneratedClassNotInConstructor - $this->escaper = ObjectManager::getInstance()->get(Escaper::class); - } - return $this->escaper; - } } diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php index 204de4d66c308..dca1c3c45e6f7 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -19,8 +19,8 @@ class PageActions extends Column { /** Url path */ - const CMS_URL_PATH_EDIT = 'cms/page/edit'; - const CMS_URL_PATH_DELETE = 'cms/page/delete'; + public const CMS_URL_PATH_EDIT = 'cms/page/edit'; + public const CMS_URL_PATH_DELETE = 'cms/page/delete'; /** * @var \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder @@ -56,6 +56,7 @@ class PageActions extends Column * @param array $data * @param string $editUrl * @param \Magento\Cms\ViewModel\Page\Grid\UrlBuilder|null $scopeUrlBuilder + * @param Escaper|null $escaper */ public function __construct( ContextInterface $context, @@ -65,7 +66,8 @@ public function __construct( array $components = [], array $data = [], $editUrl = self::CMS_URL_PATH_EDIT, - ?\Magento\Cms\ViewModel\Page\Grid\UrlBuilder $scopeUrlBuilder = null + ?\Magento\Cms\ViewModel\Page\Grid\UrlBuilder $scopeUrlBuilder = null, + ?Escaper $escaper = null ) { $this->urlBuilder = $urlBuilder; $this->actionUrlBuilder = $actionUrlBuilder; @@ -73,6 +75,7 @@ public function __construct( parent::__construct($context, $uiComponentFactory, $components, $data); $this->scopeUrlBuilder = $scopeUrlBuilder ?: ObjectManager::getInstance() ->get(\Magento\Cms\ViewModel\Page\Grid\UrlBuilder::class); + $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class); } /** @@ -88,7 +91,7 @@ public function prepareDataSource(array $dataSource) 'href' => $this->urlBuilder->getUrl($this->editUrl, ['page_id' => $item['page_id']]), 'label' => __('Edit'), ]; - $title = $this->getEscaper()->escapeHtml($item['title']); + $title = $this->escaper->escapeHtml($item['title']); $item[$name]['delete'] = [ 'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_DELETE, ['page_id' => $item['page_id']]), 'label' => __('Delete'), @@ -115,18 +118,4 @@ public function prepareDataSource(array $dataSource) return $dataSource; } - - /** - * Get instance of escaper - * - * @return Escaper - * @deprecated 101.0.7 - */ - private function getEscaper() - { - if (!$this->escaper) { - $this->escaper = ObjectManager::getInstance()->get(Escaper::class); - } - return $this->escaper; - } }