Skip to content

Commit ff71237

Browse files
authored
Merge branch '2.4-develop' into spartans_pr_25062025
2 parents fe34257 + 6bdad31 commit ff71237

File tree

172 files changed

+1112
-861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+1112
-861
lines changed
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
<?php
22
/**
3-
* Copyright 2014 Adobe
3+
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
66

77
/** @var $block \Magento\Catalog\Block\Product\View */
8+
/** @var $escaper \Magento\Framework\Escaper */
9+
10+
$product = $block->getProduct();
811
?>
912

1013
<meta property="og:type" content="product" />
1114
<meta property="og:title"
12-
content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getName())) ?>" />
15+
content="<?= $escaper->escapeHtmlAttr($block->stripTags($product->getName())) ?>" />
1316
<meta property="og:image"
14-
content="<?= $block->escapeUrl($block->getImage($block->getProduct(), 'product_base_image')->getImageUrl()) ?>" />
17+
content="<?= $escaper->escapeUrl($block->getImage($product, 'product_base_image')->getImageUrl()) ?>" />
1518
<meta property="og:description"
16-
content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getShortDescription())) ?>" />
17-
<meta property="og:url" content="<?= $block->escapeUrl($block->getProduct()->getProductUrl()) ?>" />
18-
<?php if ($priceAmount = $block->getProduct()
19+
content="<?= $escaper->escapeHtmlAttr($block->stripTags($product->getShortDescription())) ?>" />
20+
<meta property="og:url" content="<?= $escaper->escapeUrl($product->getProductUrl()) ?>" />
21+
<?php if ($product->getCanShowPrice() !== false && $priceAmount = $product
1922
->getPriceInfo()
2023
->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)
2124
->getAmount()):?>
22-
<meta property="product:price:amount" content="<?= $block->escapeHtmlAttr($priceAmount) ?>"/>
25+
<meta property="product:price:amount" content="<?= $escaper->escapeHtmlAttr($priceAmount) ?>"/>
2326
<?= $block->getChildHtml('meta.currency') ?>
2427
<?php endif;?>

app/code/Magento/Cms/Model/Page/DataProvider.php

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
namespace Magento\Cms\Model\Page;
77

88
use Magento\Cms\Api\Data\PageInterface;
9-
use Magento\Cms\Api\PageRepositoryInterface;
10-
use Magento\Cms\Model\PageFactory;
9+
use Magento\Cms\Model\Page\Service\PageService;
1110
use Magento\Cms\Model\ResourceModel\Page\CollectionFactory;
1211
use Magento\Framework\App\ObjectManager;
1312
use Magento\Framework\App\Request\DataPersistorInterface;
@@ -33,11 +32,6 @@ class DataProvider extends ModifierPoolDataProvider
3332
*/
3433
protected $loadedData;
3534

36-
/**
37-
* @var PageRepositoryInterface
38-
*/
39-
private $pageRepository;
40-
4135
/**
4236
* @var AuthorizationInterface
4337
*/
@@ -49,14 +43,9 @@ class DataProvider extends ModifierPoolDataProvider
4943
private $request;
5044

5145
/**
52-
* @var CustomLayoutManagerInterface
46+
* @var PageService
5347
*/
54-
private $customLayoutManager;
55-
56-
/**
57-
* @var PageFactory
58-
*/
59-
private $pageFactory;
48+
private $pageService;
6049

6150
/**
6251
* @var LoggerInterface
@@ -74,9 +63,7 @@ class DataProvider extends ModifierPoolDataProvider
7463
* @param PoolInterface|null $pool
7564
* @param AuthorizationInterface|null $auth
7665
* @param RequestInterface|null $request
77-
* @param CustomLayoutManagerInterface|null $customLayoutManager
78-
* @param PageRepositoryInterface|null $pageRepository
79-
* @param PageFactory|null $pageFactory
66+
* @param PageService|null $pageService
8067
* @param LoggerInterface|null $logger
8168
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8269
*/
@@ -91,9 +78,7 @@ public function __construct(
9178
?PoolInterface $pool = null,
9279
?AuthorizationInterface $auth = null,
9380
?RequestInterface $request = null,
94-
?CustomLayoutManagerInterface $customLayoutManager = null,
95-
?PageRepositoryInterface $pageRepository = null,
96-
?PageFactory $pageFactory = null,
81+
?PageService $pageService = null,
9782
?LoggerInterface $logger = null
9883
) {
9984
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
@@ -102,10 +87,7 @@ public function __construct(
10287
$this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class);
10388
$this->meta = $this->prepareMeta($this->meta);
10489
$this->request = $request ?? ObjectManager::getInstance()->get(RequestInterface::class);
105-
$this->customLayoutManager = $customLayoutManager
106-
?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
107-
$this->pageRepository = $pageRepository ?? ObjectManager::getInstance()->get(PageRepositoryInterface::class);
108-
$this->pageFactory = $pageFactory ?: ObjectManager::getInstance()->get(PageFactory::class);
90+
$this->pageService = $pageService ?: ObjectManager::getInstance()->get(PageService::class);
10991
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
11092
}
11193

@@ -150,22 +132,16 @@ private function getCurrentPage(): PageInterface
150132
{
151133
$pageId = $this->getPageId();
152134
if ($pageId) {
153-
try {
154-
$page = $this->pageRepository->getById($pageId);
155-
} catch (LocalizedException $exception) {
156-
$page = $this->pageFactory->create();
157-
}
158-
159-
return $page;
135+
return $this->pageService->getPageById($pageId);
160136
}
161137

162138
$data = $this->dataPersistor->get('cms_page');
163139
if (empty($data)) {
164-
return $this->pageFactory->create();
140+
return $this->pageService->createPageFactory();
165141
}
166142
$this->dataPersistor->clear('cms_page');
167143

168-
return $this->pageFactory->create()
144+
return $this->pageService->createPageFactory()
169145
->setData($data);
170146
}
171147

@@ -215,12 +191,15 @@ public function getMeta()
215191

216192
$page = null;
217193
try {
218-
$page = $this->pageRepository->getById($this->getPageId());
219-
if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
220-
$options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
221-
}
222-
foreach ($this->customLayoutManager->fetchAvailableFiles($page) as $layoutFile) {
223-
$options[] = ['label' => $layoutFile, 'value' => $layoutFile];
194+
$pageId = $this->getPageId();
195+
if ($pageId) {
196+
$page = $this->pageService->getPageById($pageId);
197+
if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
198+
$options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
199+
}
200+
foreach ($this->pageService->fetchAvailableCustomLayouts($page) as $layoutFile) {
201+
$options[] = ['label' => $layoutFile, 'value' => $layoutFile];
202+
}
224203
}
225204
} catch (LocalizedException $e) {
226205
$this->logger->error($e->getMessage());
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
declare(strict_types=1);
3+
/**
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
6+
*/
7+
namespace Magento\Cms\Model\Page\Service;
8+
9+
use Magento\Cms\Api\Data\PageInterface;
10+
use Magento\Cms\Api\PageRepositoryInterface;
11+
use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
12+
use Magento\Cms\Model\PageFactory;
13+
use Magento\Framework\Exception\LocalizedException;
14+
15+
/**
16+
* Cms Page Service Class
17+
*/
18+
class PageService
19+
{
20+
/**
21+
* @param PageRepositoryInterface $pageRepository
22+
* @param PageFactory $pageFactory
23+
* @param CustomLayoutManagerInterface $customLayoutManager
24+
*/
25+
public function __construct(
26+
private readonly PageRepositoryInterface $pageRepository,
27+
private readonly PageFactory $pageFactory,
28+
private readonly CustomLayoutManagerInterface $customLayoutManager,
29+
) {
30+
}
31+
32+
/**
33+
* To get the page by its ID. If the page not exists, a new page instance is returned
34+
*
35+
* @param int $id
36+
* @return PageInterface
37+
*/
38+
public function getPageById(int $id): PageInterface
39+
{
40+
try {
41+
return $this->pageRepository->getById($id);
42+
} catch (LocalizedException) {
43+
return $this->pageFactory->create();
44+
}
45+
}
46+
47+
/**
48+
* To create pagefactory class
49+
*
50+
* @return PageInterface
51+
*/
52+
public function createPageFactory(): PageInterface
53+
{
54+
return $this->pageFactory->create();
55+
}
56+
57+
/**
58+
* Fetches the available custom layouts for a given page.
59+
*
60+
* @param PageInterface $page
61+
* @return array
62+
*/
63+
public function fetchAvailableCustomLayouts(PageInterface $page): array
64+
{
65+
return $this->customLayoutManager->fetchAvailableFiles($page);
66+
}
67+
}

app/code/Magento/Cms/Test/Mftf/Test/AdminAddUpdateDeleteWidgetOfTypeCatalogProductLinkTypeTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<description value="Admin should be able to create widget type of Catalog product link and shown on storefront"/>
1717
<severity value="MAJOR"/>
1818
<testCaseId value="MC-12209"/>
19-
<skip>
20-
<issueId value="ACQE-4481"/>
21-
</skip>
2219
</annotations>
2320

2421
<before>

0 commit comments

Comments
 (0)