Skip to content

Commit bafba2a

Browse files
Merge pull request #9186 from magento-gl/compr_author
[Bluetooth] Community Pull Requests delivery SEP
2 parents df07984 + 5c24c15 commit bafba2a

File tree

12 files changed

+321
-79
lines changed

12 files changed

+321
-79
lines changed

app/code/Magento/Backend/view/adminhtml/templates/dashboard/totalbar/refreshstatistics.phtml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
/** @var \Magento\Backend\Block\Template $block */
8+
/** @var \Magento\Framework\Escaper $escaper */
69
?>
710
<div class="page-actions">
811
<div class="page-actions-inner">
912
<div class="page-actions-buttons">
1013
<?= $block->getChildHtml() ?>
1114

15+
<?php if ($block->getAuthorization()->isAllowed('Magento_Reports::statistics')): ?>
1216
<form class="action-element"
13-
action="<?= $block->escapeUrl($block->getUrl('*/*/refreshStatistics')) ?>"
17+
action="<?= $escaper->escapeUrl($block->getUrl('*/*/refreshStatistics')) ?>"
1418
method="post">
1519
<input
1620
name="form_key"
1721
type="hidden"
18-
value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>"/>
22+
value="<?= $escaper->escapeHtmlAttr($block->getFormKey()) ?>"/>
1923
<button
2024
class="action-primary"
2125
type="submit"
22-
title="<?= $block->escapeHtmlAttr(__('Reload Data')) ?>">
23-
<?= $block->escapeHtml(__('Reload Data')) ?>
26+
title="<?= $escaper->escapeHtmlAttr(__('Reload Data')) ?>">
27+
<?= $escaper->escapeHtml(__('Reload Data')) ?>
2428
</button>
2529
</form>
30+
<?php endif; ?>
2631
</div>
2732
</div>
2833
</div>

app/code/Magento/Developer/Console/Command/DiInfoCommand.php

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,26 @@
77
namespace Magento\Developer\Console\Command;
88

99
use Magento\Developer\Model\Di\Information;
10+
use Magento\Framework\ObjectManagerInterface;
1011
use Symfony\Component\Console\Command\Command;
1112
use Symfony\Component\Console\Exception\InvalidArgumentException;
1213
use Symfony\Component\Console\Helper\Table;
1314
use Symfony\Component\Console\Input\InputArgument;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Output\OutputInterface;
17+
use Magento\Framework\App\AreaList;
18+
use Magento\Framework\App\Area;
1619

20+
/**
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
*/
1723
class DiInfoCommand extends Command
1824
{
25+
/**
26+
* @var ObjectManagerInterface
27+
*/
28+
private ObjectManagerInterface $objectManager;
29+
1930
/**
2031
* Command name
2132
*/
@@ -26,18 +37,34 @@ class DiInfoCommand extends Command
2637
*/
2738
public const CLASS_NAME = 'class';
2839

40+
/**
41+
* Area name
42+
*/
43+
public const AREA_CODE = 'area';
44+
2945
/**
3046
* @var Information
3147
*/
32-
private $diInformation;
48+
private Information $diInformation;
49+
50+
/**
51+
* @var AreaList
52+
*/
53+
private AreaList $areaList;
3354

3455
/**
3556
* @param Information $diInformation
57+
* @param ObjectManagerInterface $objectManager
58+
* @param AreaList|null $areaList
3659
*/
3760
public function __construct(
38-
Information $diInformation
61+
Information $diInformation,
62+
ObjectManagerInterface $objectManager,
63+
?AreaList $areaList = null
3964
) {
4065
$this->diInformation = $diInformation;
66+
$this->objectManager = $objectManager;
67+
$this->areaList = $areaList ?? \Magento\Framework\App\ObjectManager::getInstance()->get(AreaList::class);
4168
parent::__construct();
4269
}
4370

@@ -49,10 +76,11 @@ public function __construct(
4976
protected function configure()
5077
{
5178
$this->setName(self::COMMAND_NAME)
52-
->setDescription('Provides information on Dependency Injection configuration for the Command.')
53-
->setDefinition([
54-
new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED, 'Class name')
55-
]);
79+
->setDescription('Provides information on Dependency Injection configuration for the Command.')
80+
->setDefinition([
81+
new InputArgument(self::CLASS_NAME, InputArgument::REQUIRED, 'Class name'),
82+
new InputArgument(self::AREA_CODE, InputArgument::OPTIONAL, 'Area Code')
83+
]);
5684

5785
parent::configure();
5886
}
@@ -154,10 +182,14 @@ private function printPlugins($className, $output, $label)
154182
*/
155183
protected function execute(InputInterface $input, OutputInterface $output)
156184
{
185+
$area = $input->getArgument(self::AREA_CODE) ?? Area::AREA_GLOBAL;
186+
if ($area !== Area::AREA_GLOBAL) {
187+
$this->setDiArea($area);
188+
}
157189
$className = $input->getArgument(self::CLASS_NAME);
158190
$output->setDecorated(true);
159191
$output->writeln('');
160-
$output->writeln(sprintf('DI configuration for the class %s in the GLOBAL area', $className));
192+
$output->writeln(sprintf('DI configuration for the class %s in the %s area', $className, strtoupper($area)));
161193

162194
if ($this->diInformation->isVirtualType($className)) {
163195
$output->writeln(
@@ -173,4 +205,39 @@ protected function execute(InputInterface $input, OutputInterface $output)
173205

174206
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
175207
}
208+
209+
/**
210+
* Set Area for DI Configuration
211+
*
212+
* @param string $area
213+
* @return void
214+
* @throws \InvalidArgumentException
215+
*/
216+
private function setDiArea(string $area): void
217+
{
218+
if ($this->validateAreaCodeFromInput($area)) {
219+
$areaOmConfiguration = $this->objectManager
220+
->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class)
221+
->load($area);
222+
223+
$this->objectManager->configure($areaOmConfiguration);
224+
225+
$this->objectManager->get(\Magento\Framework\Config\ScopeInterface::class)
226+
->setCurrentScope($area);
227+
} else {
228+
throw new InvalidArgumentException(sprintf('The "%s" area code does not exist', $area));
229+
}
230+
}
231+
232+
/**
233+
* Validate Input
234+
*
235+
* @param string $area
236+
* @return bool
237+
*/
238+
private function validateAreaCodeFromInput($area): bool
239+
{
240+
$availableAreaCodes = $this->areaList->getCodes();
241+
return in_array($area, $availableAreaCodes, true);
242+
}
176243
}

app/code/Magento/Review/view/frontend/templates/helper/summary.phtml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/**
88
* @var \Magento\Review\Block\Product\ReviewRenderer $block
99
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
10+
* @var \Magento\Framework\Escaper $escaper
1011
*/
1112

1213
$url = $block->getReviewsUrl() . '#reviews';
@@ -18,43 +19,37 @@ $urlForm = $block->getReviewsUrl() . '#review-form';
1819
itemtype="http://schema.org/AggregateRating">
1920
<?php if ($rating):?>
2021
<div class="rating-summary">
21-
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
22+
<span class="label"><span><?= $escaper->escapeHtml(__('Rating')) ?>:</span></span>
2223
<div class="rating-result"
23-
id="rating-result_<?= $block->escapeHtmlAttr($block->getProduct()->getId()) ?>"
24-
title="<?= $block->escapeHtmlAttr($rating) ?>%"
25-
>
26-
<span>
24+
id="rating-result_<?= $escaper->escapeHtmlAttr($block->getProduct()->getId()) ?>"
25+
title="<?= $escaper->escapeHtmlAttr($rating); ?>%">
26+
<span style="width: <?= $escaper->escapeHtmlAttr($rating); ?>%;">
2727
<span>
28-
<span itemprop="ratingValue"><?= $block->escapeHtml($rating); ?>
28+
<span itemprop="ratingValue"><?= $escaper->escapeHtml($rating); ?>
2929
</span>% of <span itemprop="bestRating">100</span>
3030
</span>
3131
</span>
3232
</div>
3333
</div>
34-
<?= /* @noEscape */
35-
$secureRenderer->renderStyleAsTag(
36-
'width:' . $block->escapeHtmlAttr($rating) . '%',
37-
'#rating-result_' . $block->getProduct()->getId() . ' span'
38-
) ?>
3934
<?php endif;?>
4035
<div class="reviews-actions">
4136
<a class="action view"
42-
href="<?= $block->escapeUrl($url) ?>">
43-
<span itemprop="reviewCount"><?= $block->escapeHtml($block->getReviewsCount()) ?></span>&nbsp;
44-
<span><?= ($block->getReviewsCount() == 1) ? $block->escapeHtml(__('Review')) :
45-
$block->escapeHtml(__('Reviews')) ?>
37+
href="<?= $escaper->escapeUrl($url) ?>">
38+
<span itemprop="reviewCount"><?= $escaper->escapeHtml($block->getReviewsCount()) ?></span>&nbsp;
39+
<span><?= ($block->getReviewsCount() == 1) ? $escaper->escapeHtml(__('Review')) :
40+
$escaper->escapeHtml(__('Reviews')) ?>
4641
</span>
4742
</a>
48-
<a class="action add" href="<?= $block->escapeUrl($urlForm) ?>">
49-
<?= $block->escapeHtml(__('Add Your Review')) ?>
43+
<a class="action add" href="<?= $escaper->escapeUrl($urlForm) ?>">
44+
<?= $escaper->escapeHtml(__('Add Your Review')) ?>
5045
</a>
5146
</div>
5247
</div>
5348
<?php elseif ($block->isReviewEnabled() && $block->getDisplayIfEmpty()): ?>
5449
<div class="product-reviews-summary empty">
5550
<div class="reviews-actions">
56-
<a class="action add" href="<?= $block->escapeUrl($urlForm) ?>">
57-
<?= $block->escapeHtml(__('Be the first to review this product')) ?>
51+
<a class="action add" href="<?= $escaper->escapeUrl($urlForm) ?>">
52+
<?= $escaper->escapeHtml(__('Be the first to review this product')) ?>
5853
</a>
5954
</div>
6055
</div>

app/code/Magento/Review/view/frontend/templates/helper/summary_short.phtml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/** @var \Magento\Review\Block\Product\ReviewRenderer $block */
88
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
9+
/** @var \Magento\Framework\Escaper $escaper */
910

1011
$url = $block->getReviewsUrl() . '#reviews';
1112
$urlForm = $block->getReviewsUrl() . '#review-form';
@@ -15,32 +16,30 @@ $urlForm = $block->getReviewsUrl() . '#review-form';
1516
<div class="product-reviews-summary short<?= !$rating ? ' no-rating' : '' ?>">
1617
<?php if ($rating):?>
1718
<div class="rating-summary">
18-
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
19+
<span class="label"><span><?= $escaper->escapeHtml(__('Rating')) ?>:</span></span>
1920
<div class="rating-result"
2021
id="rating-result_<?= /* @noEscape */ $block->getProduct()->getId() ?>"
21-
title="<?= $block->escapeHtmlAttr($rating) ?>%">
22-
<span><span><?= $block->escapeHtml($rating) ?>%</span></span>
22+
title="<?= $escaper->escapeHtmlAttr($rating) ?>%">
23+
<span style="width: <?= $escaper->escapeHtmlAttr($rating) ?>%;">
24+
<span><?= $escaper->escapeHtml($rating) ?>%</span>
25+
</span>
2326
</div>
24-
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
25-
'width:' . $block->escapeHtmlAttr($rating) . '%',
26-
'#rating-result_' . $block->getProduct()->getId() . ' span'
27-
) ?>
2827
</div>
2928
<?php endif;?>
3029
<div class="reviews-actions">
3130
<a class="action view"
32-
href="<?= $block->escapeUrl($url) ?>"><?= $block->escapeHtml($block->getReviewsCount()) ?>
31+
href="<?= $escaper->escapeUrl($url) ?>"><?= $escaper->escapeHtml($block->getReviewsCount()) ?>
3332
&nbsp;<span><?= ($block->getReviewsCount() == 1) ?
34-
$block->escapeHtml(__('Review')) : $block->escapeHtml(__('Reviews')) ?>
33+
$escaper->escapeHtml(__('Review')) : $escaper->escapeHtml(__('Reviews')) ?>
3534
</span>
3635
</a>
3736
</div>
3837
</div>
3938
<?php elseif ($block->isReviewEnabled() && $block->getDisplayIfEmpty()): ?>
4039
<div class="product-reviews-summary short empty">
4140
<div class="reviews-actions">
42-
<a class="action add" href="<?= $block->escapeUrl($urlForm) ?>">
43-
<?= $block->escapeHtml(__('Be the first to review this product')) ?>
41+
<a class="action add" href="<?= $escaper->escapeUrl($urlForm) ?>">
42+
<?= $escaper->escapeHtml(__('Be the first to review this product')) ?>
4443
</a>
4544
</div>
4645
</div>

app/code/Magento/Review/view/frontend/templates/product/view/list.phtml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,12 @@ $format = $block->getDateFormat() ?: \IntlDateFormatter::SHORT;
4949
title="<?= $escaper->escapeHtmlAttr($_vote->getPercent()) ?>%">
5050
<meta itemprop="worstRating" content="1"/>
5151
<meta itemprop="bestRating" content="100"/>
52-
<span>
52+
<span style="width: <?= $escaper->escapeHtml($_vote->getPercent()) ?>%;">
5353
<span itemprop="ratingValue">
5454
<?= $escaper->escapeHtml($_vote->getPercent()) ?>%
5555
</span>
5656
</span>
5757
</div>
58-
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
59-
'width:' . $_vote->getPercent() . '%',
60-
'div#review_' . $_review->getReviewId()
61-
. '_vote_' . $_vote->getVoteId() . ' span'
62-
) ?>
6358
</div>
6459
<?php endforeach; ?>
6560
</div>

app/code/Magento/Review/view/frontend/templates/view.phtml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,48 @@
77
/**
88
* @var \Magento\Review\Block\View $block
99
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
10+
* @var \Magento\Framework\Escaper $escaper
1011
*/
1112
?>
1213
<?php if ($block->getProductData()->getId()): ?>
1314
<div class="product-review">
1415
<div class="page-title-wrapper">
15-
<h1><?= $block->escapeHtml(__('Review Details')) ?></h1>
16+
<h1><?= $escaper->escapeHtml(__('Review Details')) ?></h1>
1617
</div>
1718
<div class="product-img-box">
18-
<a href="<?= $block->escapeUrl($block->getProductData()->getProductUrl()) ?>">
19-
<?= $block->getImage($block->getProductData(), 'product_base_image', ['class' => 'product-image'])->toHtml()
19+
<a href="<?= $escaper->escapeUrl($block->getProductData()->getProductUrl()) ?>">
20+
<?= $block->getImage($block->getProductData(), 'product_base_image', [
21+
'class' => 'product-image'])->toHtml()
2022
?>
2123
</a>
2224
<?php if ($block->getRating() && $block->getRating()->getSize()): ?>
23-
<p><?= $block->escapeHtml(__('Average Customer Rating')) ?>:</p>
25+
<p><?= $escaper->escapeHtml(__('Average Customer Rating')) ?>:</p>
2426
<?= $block->getReviewsSummaryHtml($block->getProductData()) ?>
2527
<?php endif; ?>
2628
</div>
2729
<div class="details">
28-
<h3 class="product-name"><?= $block->escapeHtml($block->getProductData()->getName()) ?></h3>
30+
<h3 class="product-name"><?= $escaper->escapeHtml($block->getProductData()->getName()) ?></h3>
2931
<?php if ($block->getRating() && $block->getRating()->getSize()): ?>
30-
<h4><?= $block->escapeHtml(__('Product Rating:')) ?></h4>
32+
<h4><?= $escaper->escapeHtml(__('Product Rating:')) ?></h4>
3133
<div class="table-wrapper">
3234
<table class="data-table review-summary-table">
33-
<caption class="table-caption"><?= $block->escapeHtml(__('Product Rating')) ?></caption>
35+
<caption class="table-caption"><?= $escaper->escapeHtml(__('Product Rating')) ?></caption>
3436
<?php foreach ($block->getRating() as $_rating): ?>
3537
<?php if ($_rating->getPercent()): ?>
3638
<?php $rating = ceil($_rating->getPercent()) ?>
3739
<tr>
3840
<td class="label" width="10%">
39-
<?= $block->escapeHtml(__($_rating->getRatingCode())) ?>
41+
<?= $escaper->escapeHtml(__($_rating->getRatingCode())) ?>
4042
</td>
4143
<td class="value">
4244
<?php $ratingId = $_rating->getRatingId() ?>
4345
<div class="rating-summary item"
44-
id="rating-div-<?= $block->escapeHtml($ratingId) ?>">
46+
id="rating-div-<?= $escaper->escapeHtml($ratingId) ?>">
4547
<div class="rating-result" title="<?= /* @noEscape */ $rating ?>%">
46-
<span>
48+
<span style="width: <?= /* @noEscape */ $rating ?>%;">
4749
<span><?= /* @noEscape */ $rating ?>%</span>
4850
</span>
4951
</div>
50-
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
51-
"width:" . /* @noEscape */ $rating . "%",
52-
'div#rating-div-'.$_rating->getRatingId().
53-
'>div.rating-result>span:first-child'
54-
) ?>
5552
</div>
5653
</td>
5754
</tr>
@@ -61,16 +58,16 @@
6158
</div>
6259
<?php endif; ?>
6360
<p class="date">
64-
<?= $block->escapeHtml(
61+
<?= $escaper->escapeHtml(
6562
__('Product Review (submitted on %1):', $block->dateFormat($block->getReviewData()->getCreatedAt()))
6663
) ?>
6764
</p>
68-
<p><?= /* @noEscape */ nl2br($block->escapeHtml($block->getReviewData()->getDetail())) ?></p>
65+
<p><?= /* @noEscape */ nl2br($escaper->escapeHtml($block->getReviewData()->getDetail())) ?></p>
6966
</div>
7067
<div class="actions">
7168
<div class="secondary">
72-
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
73-
<span><?= $block->escapeHtml(__('Back to Product Reviews')) ?></span>
69+
<a class="action back" href="<?= $escaper->escapeUrl($block->getBackUrl()) ?>">
70+
<span><?= $escaper->escapeHtml(__('Back to Product Reviews')) ?></span>
7471
</a>
7572
</div>
7673
</div>

0 commit comments

Comments
 (0)