Skip to content

Commit 23fb914

Browse files
author
Stanislav Idolov
committed
#27536: Review fixes
1 parent 123d06a commit 23fb914

File tree

4 files changed

+41
-80
lines changed

4 files changed

+41
-80
lines changed

app/code/Magento/MediaContentCatalog/Observer/Category.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,17 @@ public function execute(Observer $observer): void
5050
/** @var CatalogCategory $model */
5151
$model = $observer->getEvent()->getData('category');
5252
if ($model instanceof AbstractModel) {
53-
$this->updateRelations($model);
54-
}
55-
}
56-
57-
/**
58-
* Update relations for the model
59-
*
60-
* @param AbstractModel $model
61-
*/
62-
private function updateRelations(AbstractModel $model): void
63-
{
64-
foreach ($this->fields as $field) {
65-
if (!$model->dataHasChangedFor($field)) {
66-
continue;
53+
foreach ($this->fields as $field) {
54+
if (!$model->dataHasChangedFor($field)) {
55+
continue;
56+
}
57+
$this->processor->execute(
58+
self::CONTENT_TYPE,
59+
$field,
60+
(string) $model->getId(),
61+
(string) $model->getData($field)
62+
);
6763
}
68-
$this->processor->execute(
69-
self::CONTENT_TYPE,
70-
$field,
71-
(string) $model->getId(),
72-
(string) $model->getData($field)
73-
);
7464
}
7565
}
7666
}

app/code/Magento/MediaContentCatalog/Observer/Product.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,19 @@ public function execute(Observer $observer): void
4949
{
5050
/** @var CatalogProduct $model */
5151
$model = $observer->getEvent()->getData('product');
52-
if ($model instanceof AbstractModel) {
53-
$this->updateRelations($model);
54-
}
55-
}
5652

57-
/**
58-
* Update relations for the model
59-
*
60-
* @param AbstractModel $model
61-
*/
62-
private function updateRelations(AbstractModel $model): void
63-
{
64-
foreach ($this->fields as $field) {
65-
if (!$model->dataHasChangedFor($field)) {
66-
continue;
53+
if ($model instanceof AbstractModel) {
54+
foreach ($this->fields as $field) {
55+
if (!$model->dataHasChangedFor($field)) {
56+
continue;
57+
}
58+
$this->processor->execute(
59+
self::CONTENT_TYPE,
60+
$field,
61+
(string) $model->getId(),
62+
(string) $model->getData($field)
63+
);
6764
}
68-
$this->processor->execute(
69-
self::CONTENT_TYPE,
70-
$field,
71-
(string) $model->getId(),
72-
(string) $model->getData($field)
73-
);
7465
}
7566
}
7667
}

app/code/Magento/MediaContentCms/Observer/Block.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,17 @@ public function execute(Observer $observer): void
5050
/** @var CmsBlock $model */
5151
$model = $observer->getEvent()->getData('object');
5252
if ($model instanceof AbstractModel) {
53-
$this->updateRelations($model);
54-
}
55-
}
56-
57-
/**
58-
* Update relations for the model
59-
*
60-
* @param AbstractModel $model
61-
*/
62-
private function updateRelations(AbstractModel $model): void
63-
{
64-
foreach ($this->fields as $field) {
65-
if (!$model->dataHasChangedFor($field)) {
66-
continue;
53+
foreach ($this->fields as $field) {
54+
if (!$model->dataHasChangedFor($field)) {
55+
continue;
56+
}
57+
$this->processor->execute(
58+
self::CONTENT_TYPE,
59+
$field,
60+
(string) $model->getId(),
61+
(string) $model->getData($field)
62+
);
6763
}
68-
$this->processor->execute(
69-
self::CONTENT_TYPE,
70-
$field,
71-
(string) $model->getId(),
72-
(string) $model->getData($field)
73-
);
7464
}
7565
}
7666
}

app/code/Magento/MediaContentCms/Observer/Page.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,17 @@ public function execute(Observer $observer): void
5050
/** @var CmsPage $model */
5151
$model = $observer->getEvent()->getData('object');
5252
if ($model instanceof AbstractModel) {
53-
$this->updateRelations($model);
54-
}
55-
}
56-
57-
/**
58-
* Update relations for the model
59-
*
60-
* @param AbstractModel $model
61-
*/
62-
private function updateRelations(AbstractModel $model): void
63-
{
64-
foreach ($this->fields as $field) {
65-
if (!$model->dataHasChangedFor($field)) {
66-
continue;
53+
foreach ($this->fields as $field) {
54+
if (!$model->dataHasChangedFor($field)) {
55+
continue;
56+
}
57+
$this->processor->execute(
58+
self::CONTENT_TYPE,
59+
$field,
60+
(string) $model->getId(),
61+
(string) $model->getData($field)
62+
);
6763
}
68-
$this->processor->execute(
69-
self::CONTENT_TYPE,
70-
$field,
71-
(string) $model->getId(),
72-
(string) $model->getData($field)
73-
);
7464
}
7565
}
7666
}

0 commit comments

Comments
 (0)