Skip to content

Commit

Permalink
✨ remove super custom code
Browse files Browse the repository at this point in the history
In previous versions of Doctrine, it was hard to act on entity load.
Since doctrine changed its internal behavior, we managed to improve the
situation as well on the bundle.

The new PostLoadDispatcherInjecttionListener class allows us to remove a
huge part of this bundle that was previously super-mega-custom.

This is awesome! But it comes with a huge refactoring, and this is not
even the last commit toward the next major version of this package.
  • Loading branch information
Nek- committed Jul 29, 2024
1 parent 6275a32 commit 728e1de
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 694 deletions.
3 changes: 1 addition & 2 deletions Tests/Event/DelayedListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Biig\Component\Domain\Event\DomainEventDispatcher;
use Biig\Component\Domain\Exception\InvalidDomainEvent;
use Biig\Component\Domain\Model\DomainModel;
use Biig\Component\Domain\PostPersistListener\DoctrinePostPersistListener;
use Biig\Component\Domain\Rule\PostPersistDomainRuleInterface;
use Biig\Component\Domain\Tests\fixtures\Entity\FakeModel;
use Biig\Component\Domain\Tests\SetupDatabaseTrait;
Expand Down Expand Up @@ -103,7 +102,7 @@ public function testItDoesNotExecuteManyTimesSameEvent()
{
// Test setup
$dispatcher = new DomainEventDispatcher();
$entityManager = $this->setupDatabase($dispatcher, 'testItInsertInBddAfterFlushing');
$entityManager = $this->setupDatabase($dispatcher, 'testItDoesNotExecuteManyTimesSameEvent');

$model = new FakeModel();
$model->setFoo(0);
Expand Down

This file was deleted.

56 changes: 0 additions & 56 deletions Tests/Model/Instantiator/DoctrineConfig/ClassMetadataTest.php

This file was deleted.

28 changes: 0 additions & 28 deletions Tests/Model/Instantiator/DoctrineConfig/InstantiatorTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testAnEntityThatDoesntHaveDispatcherWhileFlushedThrowAnError()
{
self::bootKernel(['debug' => true]);
// You should not create your entites this way in your own code !
// Use the Biig\Component\Domain\Model\Instantiator\Instantiator service to instanciate your entities.
// Use the Biig\Component\Domain\Model\Instantiator\Instantiator service to instantiate your entities.
$model = new FakeModel();

$this->expectException(FlushedEntityDoesntContainsDispatcherException::class);
Expand Down
3 changes: 0 additions & 3 deletions Tests/SetupDatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ private function setupDatabase(DomainEventDispatcherInterface $dispatcher, strin
copy(__DIR__ . '/fixtures/dbtest/initial_fake_model.db', $this->dbPath);

$config = ORMSetup::createAttributeMetadataConfiguration(array(__DIR__ . '/../fixtures/Entity'), true);
$config->setClassMetadataFactoryName(ClassMetadataFactory::class);
$conn = [
'driver' => 'pdo_sqlite',
'path' => $this->dbPath,
Expand All @@ -29,8 +28,6 @@ private function setupDatabase(DomainEventDispatcherInterface $dispatcher, strin
$entityManager->getEventManager()->addEventSubscriber(new DoctrinePostPersistListener($dispatcher));
$entityManager->getEventManager()->addEventSubscriber(new PostLoadDispatcherInjectionListener($dispatcher));

$entityManager->getMetadataFactory()->setDispatcher($dispatcher);

return $entityManager;
}

Expand Down

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions Tests/Symfony/DependencyInjection/DomainExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testItAddsDoctrinePostPersistListenerToContainer()
$extension->load($config, $container);

$array = [
'biig_domain.postload_subscriber' => [[]],
"biig_domain.post_persist_listener.doctrine_default" => [
[
"connection" => "default"
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": ">=8.1",
"symfony/event-dispatcher": "^5.0|^6.0|^7.0",
"doctrine/doctrine-bundle": "^1.8|^2.0",
"doctrine/orm": "^2.6.3"
"doctrine/orm": "^2.18.3"
},
"authors": [
{
Expand All @@ -16,7 +16,7 @@
],
"require-dev": {
"phpunit/phpunit": "^9.5 || ^10",
"doctrine/orm": "^2.6.3",
"doctrine/orm": "^2.18.3",
"friendsofphp/php-cs-fixer": "^3.49.0",
"symfony/framework-bundle": "^5.0 || ^6.0",
"phpspec/prophecy-phpunit": "^2.0.1",
Expand Down
Loading

0 comments on commit 728e1de

Please sign in to comment.