Skip to content

Commit

Permalink
fix(NodeTypes): Do not update DB schema when importing a NodeType JSO…
Browse files Browse the repository at this point in the history
…N file. Fixes `app:install` command which updated JSON files and schema instead of just importing Types.

Use `app:migrate` if you want to upgrade your DB with migrations and rewrite your JSON files.
  • Loading branch information
ambroisemaupate committed Mar 7, 2024
1 parent b096e9d commit 80f7a86
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions lib/RoadizCoreBundle/src/Importer/NodeTypesImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,16 @@

use JMS\Serializer\DeserializationContext;
use JMS\Serializer\SerializerInterface;
use RZ\Roadiz\Core\Handlers\HandlerFactoryInterface;
use RZ\Roadiz\CoreBundle\Entity\NodeType;
use RZ\Roadiz\CoreBundle\EntityHandler\NodeTypeHandler;
use RZ\Roadiz\CoreBundle\Serializer\ObjectConstructor\TypedObjectConstructorInterface;

class NodeTypesImporter implements EntityImporterInterface
{
protected SerializerInterface $serializer;
protected HandlerFactoryInterface $handlerFactory;


public function __construct(SerializerInterface $serializer, HandlerFactoryInterface $handlerFactory)
{
$this->serializer = $serializer;
$this->handlerFactory = $handlerFactory;
public function __construct(
protected SerializerInterface $serializer
) {
}

/**
* @inheritDoc
*/
public function supports(string $entityClass): bool
{
return $entityClass === NodeType::class;
Expand All @@ -36,7 +26,7 @@ public function supports(string $entityClass): bool
*/
public function import(string $serializedData): bool
{
$nodeType = $this->serializer->deserialize(
$this->serializer->deserialize(
$serializedData,
NodeType::class,
'json',
Expand All @@ -45,10 +35,6 @@ public function import(string $serializedData): bool
->setAttribute(TypedObjectConstructorInterface::FLUSH_NEW_OBJECTS, true)
);

/** @var NodeTypeHandler $nodeTypeHandler */
$nodeTypeHandler = $this->handlerFactory->getHandler($nodeType);
$nodeTypeHandler->updateSchema();

return true;
}
}

0 comments on commit 80f7a86

Please sign in to comment.