Skip to content

Commit de5e19a

Browse files
committed
migrate component properties to json string
1 parent f3c9ee3 commit de5e19a

22 files changed

+68
-34
lines changed

DependencyInjection/Compiler/AddComponentDataResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AddComponentDataResolver implements CompilerPassInterface
1313
/**
1414
* {@inheritdoc}
1515
*/
16-
public function process(ContainerBuilder $container)
16+
public function process(ContainerBuilder $container): void
1717
{
1818
$actionManager = $container->findDefinition('spy_timeline.action_manager');
1919
$componentDataResolver = $container->findDefinition('spy_timeline.resolve_component.resolver');

DependencyInjection/Compiler/AddDeliveryMethodCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AddDeliveryMethodCompilerPass implements CompilerPassInterface
1010
/**
1111
* {@inheritdoc}
1212
*/
13-
public function process(ContainerBuilder $container)
13+
public function process(ContainerBuilder $container): void
1414
{
1515
// we only do a call if the delivery method is immediate.
1616
if ($container->getParameter('spy_timeline.spread.deployer.delivery') !== "immediate") {

DependencyInjection/Compiler/AddFilterCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AddFilterCompilerPass implements CompilerPassInterface
1010
/**
1111
* {@inheritdoc}
1212
*/
13-
public function process(ContainerBuilder $container)
13+
public function process(ContainerBuilder $container): void
1414
{
1515
$filterManager = $container->getDefinition('spy_timeline.filter.manager');
1616

DependencyInjection/Compiler/AddLocatorCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AddLocatorCompilerPass implements CompilerPassInterface
1616
/**
1717
* {@inheritdoc}
1818
*/
19-
public function process(ContainerBuilder $container)
19+
public function process(ContainerBuilder $container): void
2020
{
2121
$parameterDefinitions = $this->getLocatorDefinitionsFromParameter($container);
2222
$taggedServiceDefinitions = $this->getLocatorDefinitionsFromTaggedServices($container);

DependencyInjection/Compiler/AddRegistryCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AddRegistryCompilerPass implements CompilerPassInterface
1010
/**
1111
* {@inheritdoc}
1212
*/
13-
public function process(ContainerBuilder $container)
13+
public function process(ContainerBuilder $container): void
1414
{
1515
if (!$container->hasParameter('spy_timeline.resolve_component.doctrine_registries')) {
1616
return;

DependencyInjection/Compiler/AddSpreadCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AddSpreadCompilerPass implements CompilerPassInterface
1010
/**
1111
* {@inheritdoc}
1212
*/
13-
public function process(ContainerBuilder $container)
13+
public function process(ContainerBuilder $container): void
1414
{
1515
$alias = $container->getAlias('spy_timeline.spread.deployer');
1616
$spreadDeployer = $container->getDefinition((string) $alias);

Driver/Doctrine/ODM/PostLoadListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function postLoad(LifecycleEventArgs $eventArgs)
2525
$entity->setData(
2626
$eventArgs->getDocumentManager()->getReference(
2727
$entity->getModel(),
28-
$entity->getIdentifier()
28+
$entity->getIdentifierMigrated() ?? $entity->getIdentifier()
2929
)
3030
);
3131
} catch (DocumentNotFoundException $e) {

Driver/Doctrine/ORM/PostLoadListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function postLoad(PostLoadEventArgs $eventArgs)
2525
$entity->setData(
2626
$eventArgs->getObjectManager()->getReference(
2727
$entity->getModel(),
28-
$entity->getIdentifier()
28+
$entity->getIdentifierMigrated() ?? $entity->getIdentifier()
2929
)
3030
);
3131
} catch (EntityNotFoundException $e) {

Driver/ODM/ActionManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function findOrCreateComponent($model, $identifier = null, $flush = true)
7575
$component = $this->objectManager
7676
->createQueryBuilder($this->componentClass)
7777
->field('model')->equals($resolvedComponentData->getModel())
78-
->field('identifier')->equals($resolvedComponentData->getIdentifier())
78+
->field('identifier')->equals($resolvedComponentData->getIdentifierMigrated() ?? $resolvedComponentData->getIdentifier())
7979
->getQuery()
8080
->getSingleResult()
8181
;

Driver/ORM/ActionManager.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,7 @@ public function findOrCreateComponent($model, $identifier = null, $flush = true)
7878
{
7979
$resolvedComponentData = $this->resolveModelAndIdentifier($model, $identifier);
8080

81-
$component = $this->getComponentRepository()
82-
->createQueryBuilder('c')
83-
->where('c.hash = :hash')
84-
->setParameter('hash', $resolvedComponentData->getHash())
85-
->getQuery()
86-
->getOneOrNullResult()
87-
;
81+
$component = $this->findComponentWithHash($resolvedComponentData->getHash());
8882

8983
if ($component) {
9084
$component->setData($resolvedComponentData->getData());
@@ -100,13 +94,23 @@ public function findOrCreateComponent($model, $identifier = null, $flush = true)
10094
*/
10195
public function findComponentWithHash($hash)
10296
{
97+
$component = $this->getComponentRepository()
98+
->createQueryBuilder('c')
99+
->where('c.hashMigrated = :hash')
100+
->setParameter('hash', $hash)
101+
->getQuery()
102+
->getOneOrNullResult();
103+
104+
if (null !== $component) {
105+
return $component;
106+
}
107+
103108
return $this->getComponentRepository()
104109
->createQueryBuilder('c')
105110
->where('c.hash = :hash')
106111
->setParameter('hash', $hash)
107112
->getQuery()
108-
->getOneOrNullResult()
109-
;
113+
->getOneOrNullResult();
110114
}
111115

112116
/**
@@ -120,12 +124,16 @@ public function findComponents(array $hashes)
120124

121125
$qb = $this->getComponentRepository()->createQueryBuilder('c');
122126

123-
return $qb->where(
124-
$qb->expr()->in('c.hash', $hashes)
125-
)
127+
$components = $qb->where($qb->expr()->in('c.hashMigrated', $hashes))
126128
->getQuery()
127-
->getResult()
128-
;
129+
->getResult();
130+
if (!empty($components)) {
131+
return $components;
132+
}
133+
134+
return $qb->where($qb->expr()->in('c.hash', $hashes))
135+
->getQuery()
136+
->getResult();
129137
}
130138

131139
protected function getQueryBuilderForSubject(ComponentInterface $subject)

0 commit comments

Comments
 (0)