Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion block accordion #81

Merged
merged 25 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7153831
prepare v2
Lucanis May 25, 2022
14f1510
new integ for v2
Lucanis Jun 2, 2022
a4d4341
add missing preview controller
Lucanis Jun 6, 2022
868463e
prepare preview
Lucanis Jun 6, 2022
58a36c3
add better integ into catalog & folders
Lucanis Jun 7, 2022
12b859b
add better integ into catalog & folders²
Lucanis Jun 7, 2022
022c97a
remove dump
Lucanis Jun 7, 2022
322e7b7
Add assets optimization for multiple configurator
lopes-vincent Jun 8, 2022
781e40f
change the way the image block is loaded
Lucanis Jun 8, 2022
a20537b
fix wrong params
Lucanis Jun 9, 2022
33c89ea
Reset CSS for TheliaBlocks
Neox63 Jul 12, 2022
11feb8c
add shortcode & reworks blocks rendering
Lucanis Jul 20, 2022
9114316
optimize theliaBlocks shortcode
Lucanis Jul 20, 2022
90b7a7a
remove debug value
Lucanis Jul 20, 2022
42e129a
add linking capability
Lucanis Jul 22, 2022
52f86eb
Add locale handling for blockgroup
Neox63 Jul 26, 2022
b5d65d4
Added props for BlocksList, CSS reset adjustments, patch annotation o…
Neox63 Jul 29, 2022
f8eb2d3
wip
Neox63 Aug 4, 2022
7cf643c
feat(documentation): first version (WIP)
Neox63 Aug 19, 2022
bc68dcd
doc changes
Neox63 Aug 19, 2022
66efc3a
Doc changes : added documentation for external plugin
Neox63 Aug 19, 2022
47b8de5
Updated documentation, added examples and more
Neox63 Aug 30, 2022
3cdddfa
Added command to convert old accordion blocks for new Thelia Blocks
Neox63 Sep 2, 2022
66d70e7
update blocks editor deps
Lucanis Sep 5, 2022
e55cfe7
rebuild vendor
Lucanis Sep 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions Command/ValidateJsonContent.php
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;
}
}
2 changes: 1 addition & 1 deletion Model/Api/ItemBlockGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function createFromTheliaModel($theliaModel, $locale = null)
}

$tableMap = new $tableMapClass();
$queryClass = $tableMap->getClassName().'Query';
$queryClass = $tableMap->getClassName() . 'Query';

if (!class_exists($queryClass)) {
return $this;
Expand Down
Loading