12 use Magento\Theme\Model\ResourceModel\Theme\Data\CollectionFactory;
35 private $themeFilesystemCollection;
42 private $themeCollectionFactory;
49 private $themeRegistration;
56 private $themeResourceModel;
65 ThemeFilesystemCollection $themeFilesystemCollection,
66 CollectionFactory $collectionFactory,
70 $this->themeFilesystemCollection = $themeFilesystemCollection;
71 $this->themeCollectionFactory = $collectionFactory;
72 $this->themeRegistration = $registration;
73 $this->themeResourceModel = $themeResourceModel;
79 public function import(array
$data)
81 $messages = [
'<info>Theme import was started.</info>'];
85 $this->themeRegistration->
register();
88 $collection = $this->themeCollectionFactory->create();
91 $themesInFs = $this->themeFilesystemCollection->getAllIds();
98 $themeFullPath =
$theme->getFullPath();
99 if (!key_exists($themeFullPath,
$data) && !in_array($themeFullPath, $themesInFs)) {
100 $this->themeResourceModel->delete(
$theme);
103 }
catch (\Exception $exception) {
104 throw new InvalidTransitionException(
__(
'%1', $exception->getMessage()), $exception);
107 $messages[] =
'<info>Theme import finished.</info>';
121 $themesInFile = array_keys(
$data);
125 $collection = $this->themeCollectionFactory->create();
129 $themesInDb[] =
$theme->getFullPath();
132 $toBeRegistered = $this->themeFilesystemCollection->getAllIds();
133 $toBeRemoved = array_diff($themesInDb, $toBeRegistered, $themesInFile);
134 $newThemes = array_diff($toBeRegistered, $themesInDb);
139 $messages[] =
'<info>The following themes will be registered:</info> ' . implode(
', ', $newThemes);
143 $messages[] =
'<info>The following themes will be removed:</info> ' . implode(
', ', $toBeRemoved);
__construct(ThemeFilesystemCollection $themeFilesystemCollection, CollectionFactory $collectionFactory, Registration $registration, ThemeResourceModel $themeResourceModel)
getWarningMessages(array $data)