-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathModelsPlugin.php
33 lines (30 loc) · 884 Bytes
/
ModelsPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
namespace Magefan\Blog\Plugin\Magento\AdminGws\Model;
class ModelsPlugin
{
/**
* @param $subject
* @param callable $proceed
* @param $model
* @return callable
*/
public function aroundCmsPageSaveBefore($subject, callable $proceed, $model)
{
$isBlogModel = ($model instanceof \Magefan\Blog\Model\Post
|| $model instanceof \Magefan\Blog\Model\Category
);
if ($isBlogModel) {
$storeId = $model->getStoreId();
if ($model->getStoreIds()) {
$model->setStoreId($model->getStoreIds());
}
}
return $proceed($model);
}
}