-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prepare v2 * new integ for v2 * add missing preview controller * prepare preview * add better integ into catalog & folders * add better integ into catalog & folders² * remove dump * Add assets optimization for multiple configurator * change the way the image block is loaded * fix wrong params * Reset CSS for TheliaBlocks * add shortcode & reworks blocks rendering * optimize theliaBlocks shortcode * remove debug value * add linking capability * Add locale handling for blockgroup * Added props for BlocksList, CSS reset adjustments, patch annotation on group api route * wip * feat(documentation): first version (WIP) * doc changes * Doc changes : added documentation for external plugin * Updated documentation, added examples and more * Added command to convert old accordion blocks for new Thelia Blocks * update blocks editor deps * rebuild vendor Co-authored-by: Vincent Lopes-Vicente <vlopes@openstudio.fr> Co-authored-by: Mathis Chambon <matchambon60@gmail.com>
- Loading branch information
1 parent
20e5c40
commit f01adab
Showing
14 changed files
with
621 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
namespace TheliaBlocks\Command; | ||
|
||
use Propel\Runtime\ActiveQuery\ModelCriteria; | ||
use Propel\Runtime\ActiveRecord\ActiveRecordInterface; | ||
use Symfony\Component\Console\Helper\ProgressBar; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpFoundation\File\File; | ||
use Thelia\Command\ContainerAwareCommand; | ||
use Thelia\Model\ConfigQuery; | ||
use Thelia\Model\FolderImage; | ||
use Thelia\Model\LangQuery; | ||
use TheliaBlocks\Model\BlockGroupI18nQuery; | ||
|
||
class ValidateJsonContent extends ContainerAwareCommand | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->setName('thelia_blocks:blocks:validate') | ||
->setDescription('Validate & update json_content structure'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$jsonContents = BlockGroupI18nQuery::create()->find(); | ||
|
||
|
||
$output->writeln('<bg=blue>============================================================= </>'); | ||
$output->writeln("<fg=blue>Thelia blocks json_content validation started</>"); | ||
$progressBar = new ProgressBar($output, $jsonContents->count()); | ||
$progressBar->start(); | ||
|
||
foreach ($jsonContents as $jsonContent) { | ||
$content = $jsonContent->getJsonContent(); | ||
|
||
$decodedJson = json_decode($content, true); | ||
|
||
foreach ($decodedJson as $key => $value) { | ||
$output->writeln("-"); | ||
$output->writeln($value["type"]["id"]); | ||
|
||
if ($value["type"]["id"] === "blockAccordion") { | ||
$oldData = $decodedJson[$key]["data"]; | ||
|
||
$group = array_map(function ($item) { | ||
if (isset($item["group"])) { | ||
$item["content"] = []; | ||
$item["content"][] = $item["group"]; | ||
|
||
unset($item["group"]); | ||
|
||
$item["content"][0]["data"] = ["content" => [$item["content"][0]["data"]]]; | ||
} | ||
|
||
return $item; | ||
}, $oldData); | ||
|
||
$decodedJson[$key]["data"] = [ | ||
"title" => "", | ||
"group" => $group | ||
]; | ||
} | ||
} | ||
|
||
|
||
$jsonContent->setJsonContent(json_encode($decodedJson)); | ||
|
||
$jsonContent->save(); | ||
|
||
$progressBar->advance(); | ||
} | ||
|
||
$progressBar->finish(); | ||
$output->writeln(""); | ||
$output->writeln("<info>Thelia blocks json_content validation ended</info>"); | ||
$output->writeln('<bg=blue>============================================================= </>'); | ||
|
||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.