Skip to content

Commit cf8c6aa

Browse files
author
Rocket Web
authored
Merge branch 'main' into ICP-7_import_all
2 parents 147482b + ab81c24 commit cf8c6aa

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

Console/Command/DumpCmsData.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class DumpCmsData extends \Symfony\Component\Console\Command\Command
2525
private const INPUT_KEY_TYPE = 'type';
2626
private const INPUT_TYPE_VALUES = ['block', 'page', 'all'];
2727
private const INPUT_KEY_IDENTIFIER = 'identifier';
28+
private const INPUT_KEY_REMOVE_ALL = 'removeAll';
2829
private \RocketWeb\CmsImportExport\Model\Service\DumpCmsDataService $dumpCmsDataService;
2930

3031
public function __construct(
@@ -51,6 +52,12 @@ protected function configure()
5152
'i',
5253
InputOption::VALUE_OPTIONAL,
5354
'identifier to process (one or CSV list)'
55+
),
56+
new InputOption(
57+
self::INPUT_KEY_REMOVE_ALL,
58+
'r',
59+
InputOption::VALUE_NONE,
60+
'Flag to remove all existing data'
5461
)
5562
]);
5663
parent::configure();
@@ -59,6 +66,7 @@ protected function configure()
5966
protected function execute(InputInterface $input, OutputInterface $output): void
6067
{
6168
$type = $input->getOption(self::INPUT_KEY_TYPE);
69+
$removeAll = (bool)$input->getOption(self::INPUT_KEY_REMOVE_ALL);
6270
if ($type === null) {
6371
throw new \RuntimeException("Type ([-t|--type) is required");
6472
}
@@ -78,6 +86,6 @@ protected function execute(InputInterface $input, OutputInterface $output): void
7886
$identifiers = explode(',', $identifiers);
7987
}
8088

81-
$this->dumpCmsDataService->execute($types, $identifiers);
89+
$this->dumpCmsDataService->execute($types, $identifiers, $removeAll);
8290
}
8391
}

Model/Service/DumpCmsDataService.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public function __construct(
4949
$this->categoryList = $categoryList;
5050
}
5151

52-
public function execute(array $types, ?array $identifiers)
52+
public function execute(array $types, ?array $identifiers, bool $removeAll)
5353
{
5454
$varDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
5555
$varPath = $this->directoryList->getPath(DirectoryList::VAR_DIR);
5656
$workingDirPath = $varPath . '/sync_cms_data';
57-
if ($varDirectory->isExist($workingDirPath)) {
57+
if ($varDirectory->isExist($workingDirPath) && $removeAll) {
5858
$varDirectory->delete($workingDirPath);
5959
}
6060

@@ -102,6 +102,9 @@ private function dumpPages(string $path, WriteInterface $varDirectory, ?array $i
102102
'content_heading' => $page->getContentHeading(),
103103

104104
];
105+
if ($page->getIsTailwindcssJitEnabled() !== null) {
106+
$jsonContent['is_tailwindcss_jit_enabled'] = $page->getIsTailwindcssJitEnabled();
107+
}
105108
$this->write($varDirectory, $jsonPath, $this->serializer->serialize($jsonContent));
106109
}
107110
}
@@ -133,6 +136,9 @@ private function dumpBlocks(string $path, WriteInterface $varDirectory, ?array $
133136
'stores' => [1],
134137
'is_active' => $block->isActive()
135138
];
139+
if ($block->getIsTailwindcssJitEnabled() !== null) {
140+
$jsonContent['is_tailwindcss_jit_enabled'] = $block->getIsTailwindcssJitEnabled();
141+
}
136142
$this->write($varDirectory, $jsonPath, $this->serializer->serialize($jsonContent));
137143
}
138144
}

Model/Service/ImportCmsDataService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ private function importBlocks(string $dirPath, ?array $identifiers): void
107107
$block->setIdentifier($jsonData['identifier']);
108108
$block->setStoreId($jsonData['stores'][0]);
109109
$block->setIsActive((bool)$jsonData['is_active']);
110+
if (isset($jsonData['is_tailwindcss_jit_enabled'])) {
111+
$block->setIsTailwindcssJitEnabled($jsonData['is_tailwindcss_jit_enabled']);
112+
}
110113

111114
try {
112115
$this->blockRepository->save($block);
@@ -154,6 +157,9 @@ private function importPages(string $dirPath, ?array $identifiers): void
154157
$page->setPageLayout($jsonData['page_layout']);
155158
$page->setContentHeading($jsonData['content_heading']);
156159
$page->setIsActive((bool)$jsonData['is_active']);
160+
if (isset($jsonData['is_tailwindcss_jit_enabled'])) {
161+
$page->setIsTailwindcssJitEnabled($jsonData['is_tailwindcss_jit_enabled']);
162+
}
157163

158164
try {
159165
$this->pageRepository->save($page);

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Options:
2929
-t, --type=TYPE Which type are we dumping - block/page/all
3030
-i, --identifier[=IDENTIFIER] identifier to process (one or CSV list)
3131
-a, --importAll Flag to import all files
32+
-r, --removeAll Flag to remove all existing data
3233
```
3334

3435
As you can see from the options, we need to define:

0 commit comments

Comments
 (0)