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

Fix deprecations #38

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 2 additions & 14 deletions src/Doctrine/EventSubscriber/PersistDomainEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@

namespace Headsnet\DomainEventsBundle\Doctrine\EventSubscriber;

use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\OnFlushEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\PersistentCollection;
use Headsnet\DomainEventsBundle\Domain\Model\ContainsEvents;
use Headsnet\DomainEventsBundle\Domain\Model\EventStore;
use Headsnet\DomainEventsBundle\Domain\Model\ReplaceableDomainEvent;

class PersistDomainEventSubscriber implements EventSubscriber
class PersistDomainEventSubscriber
{
private EventStore $eventStore;

Expand All @@ -29,24 +27,14 @@ public function __construct(EventStore $eventStore)
$this->eventStore = $eventStore;
}

/**
* @return string[]
*/
public function getSubscribedEvents(): array
{
return [
Events::onFlush,
];
}

public function onFlush(OnFlushEventArgs $args): void
{
$this->persistEntityDomainEvents($args);
}

private function persistEntityDomainEvents(OnFlushEventArgs $args): void
{
$uow = $args->getEntityManager()->getUnitOfWork();
$uow = $args->getObjectManager()->getUnitOfWork();

$sources = [
$uow->getScheduledEntityInsertions(),
Expand Down
11 changes: 1 addition & 10 deletions src/Doctrine/EventSubscriber/TableNameEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

namespace Headsnet\DomainEventsBundle\Doctrine\EventSubscriber;

use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Events;

final class TableNameEventSubscriber implements EventSubscriber
final class TableNameEventSubscriber
{
private string $tableName;

Expand All @@ -25,13 +23,6 @@ public function __construct(string $tableName)
$this->tableName = $tableName;
}

public function getSubscribedEvents(): array
{
return [
Events::loadClassMetadata,
];
}

public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
{
$classMetadata = $eventArgs->getClassMetadata();
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
class="Headsnet\DomainEventsBundle\Doctrine\EventSubscriber\TableNameEventSubscriber"
public="false">
<argument>%headsnet_domain_events.table_name%</argument>
<tag name="doctrine.event_subscriber" connection="default"/>
<tag name="doctrine.event_listener" event="loadClassMetadata" connection="default"/>
</service>

<service id="headsnet_domain_events.event_subscriber.persister"
class="Headsnet\DomainEventsBundle\Doctrine\EventSubscriber\PersistDomainEventSubscriber"
public="false">
<argument type="service" id="headsnet_domain_events.repository.event_store_doctrine"/>
<tag name="doctrine.event_subscriber" connection="default" priority="10"/>
<tag name="doctrine.event_listener" event="onFlush" connection="default" priority="10"/>
</service>

<service id="headsnet_domain_events.repository.event_store_doctrine"
Expand Down
Loading