Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-theme
Observer
CleanThemeRelatedContentObserver.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Theme\Observer
;
8
9
use
Magento\Framework\Event\Observer
as
EventObserver
;
10
use
Magento\Framework\Event\ObserverInterface
;
11
use
Magento\Theme\Model\Theme
;
12
13
class
CleanThemeRelatedContentObserver
implements
ObserverInterface
14
{
18
protected
$themeImageFactory
;
19
23
protected
$updateCollection
;
24
28
protected
$themeConfig
;
29
35
public
function
__construct
(
36
\
Magento
\Framework\View\Design\
Theme
\ImageFactory
$themeImageFactory
,
37
\
Magento
\Widget\Model\
ResourceModel
\Layout\Update\
Collection
$updateCollection
,
38
\
Magento
\
Theme
\Model\Config\Customization
$themeConfig
39
) {
40
$this->themeImageFactory =
$themeImageFactory
;
41
$this->updateCollection =
$updateCollection
;
42
$this->themeConfig =
$themeConfig
;
43
}
44
52
public
function
execute
(
EventObserver
$observer
)
53
{
54
$theme
=
$observer
->getEvent()->getData(
'theme'
);
55
if
(!(
$theme
instanceof \
Magento
\Framework\View\Design\
ThemeInterface
)) {
56
return
;
57
}
59
if
($this->themeConfig->isThemeAssignedToStore(
$theme
)) {
60
throw
new \Magento\Framework\Exception\LocalizedException(
__
(
'Theme isn\'t deletable.'
));
61
}
62
$this->themeImageFactory->create([
'theme'
=>
$theme
])->removePreviewImage();
63
$this->updateCollection->addThemeFilter(
$theme
->getId())->
delete
();
64
}
65
}
Magento\Theme\Model\Theme
Definition:
Theme.php:36
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
Magento\Theme\Model\Theme\Collection
Definition:
Collection.php:13
Magento\Framework\Event\ObserverInterface
Definition:
ObserverInterface.php:16
__
__()
Definition:
__.php:13
Magento\Framework\View\Design\ThemeInterface
Definition:
ThemeInterface.php:14
Magento\Theme\Observer\CleanThemeRelatedContentObserver\$updateCollection
$updateCollection
Definition:
CleanThemeRelatedContentObserver.php:23
Magento\Theme\Observer\CleanThemeRelatedContentObserver\__construct
__construct(\Magento\Framework\View\Design\Theme\ImageFactory $themeImageFactory, \Magento\Widget\Model\ResourceModel\Layout\Update\Collection $updateCollection, \Magento\Theme\Model\Config\Customization $themeConfig)
Definition:
CleanThemeRelatedContentObserver.php:35
Magento\Theme\Model\Theme
Definition:
CollectionTest.php:10
$observer
$observer
Definition:
second_website_with_second_currency.php:38
Magento\Theme\Observer\CleanThemeRelatedContentObserver\$themeConfig
$themeConfig
Definition:
CleanThemeRelatedContentObserver.php:28
Magento\Framework\Event\Observer
Definition:
Collection.php:12
Magento
$theme
$theme
Definition:
theme_rollback.php:9
Magento\Theme\Observer
Definition:
ApplyThemeCustomizationObserver.php:7
Magento\Theme\Observer\CleanThemeRelatedContentObserver
Definition:
CleanThemeRelatedContentObserver.php:13
Magento\Framework\Event\ObserverInterface\execute
execute(Observer $observer)
Magento\Theme\Observer\CleanThemeRelatedContentObserver\$themeImageFactory
$themeImageFactory
Definition:
CleanThemeRelatedContentObserver.php:18