Skip to content

Commit

Permalink
Leverage generic persistence event classes
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed May 1, 2022
1 parent 6d5fc5b commit bf2ca44
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
9 changes: 3 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Event/LifecycleEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\Event\LifecycleEventArgs as BaseLifecycleEventArgs;

use function assert;

/**
* Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions
* of documents.
*
* @template-extends BaseLifecycleEventArgs<DocumentManager>
*/
class LifecycleEventArgs extends BaseLifecycleEventArgs
{
Expand All @@ -22,9 +22,6 @@ public function getDocument(): object

public function getDocumentManager(): DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);

return $dm;
return $this->getObjectManager();
}
}
10 changes: 4 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Event/LoadClassMetadataEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
namespace Doctrine\ODM\MongoDB\Event;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\Persistence\Event\LoadClassMetadataEventArgs as BaseLoadClassMetadataEventArgs;

use function assert;

/**
* Class that holds event arguments for a loadMetadata event.
*
* @template-extends BaseLoadClassMetadataEventArgs<ClassMetadata<object>, DocumentManager>
*/
final class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
{
public function getDocumentManager(): DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);

return $dm;
return $this->getObjectManager();
}
}
9 changes: 3 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Event/ManagerEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\Event\ManagerEventArgs as BaseManagerEventArgs;

use function assert;

/**
* Provides event arguments for the flush events.
*
* @template-extends BaseManagerEventArgs<DocumentManager>
*/
class ManagerEventArgs extends BaseManagerEventArgs
{
public function getDocumentManager(): DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);

return $dm;
return $this->getObjectManager();
}
}
8 changes: 3 additions & 5 deletions lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\Event\OnClearEventArgs as BaseOnClearEventArgs;

use function assert;
use function func_num_args;
use function method_exists;
use function trigger_deprecation;

/**
* Provides event arguments for the onClear event.
*
* @template-extends BaseOnClearEventArgs<DocumentManager>
*/
final class OnClearEventArgs extends BaseOnClearEventArgs
{
Expand Down Expand Up @@ -50,10 +51,7 @@ public function __construct($objectManager, $entityClass = null)

public function getDocumentManager(): DocumentManager
{
$dm = $this->getObjectManager();
assert($dm instanceof DocumentManager);

return $dm;
return $this->getObjectManager();
}

/**
Expand Down

0 comments on commit bf2ca44

Please sign in to comment.