Skip to content

Commit

Permalink
Change more annotations to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Mar 6, 2024
1 parent f1211cc commit 406fed3
Showing 1 changed file with 13 additions and 17 deletions.
Expand Up @@ -9,6 +9,7 @@
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;
use Doctrine\ODM\MongoDB\Types\Type;
use MongoDB\Client;
use MongoDB\Driver\Session;
use PHPUnit\Framework\Assert;
Expand Down Expand Up @@ -199,22 +200,16 @@ private function createFailPoint(string $failCommand): void
}
}

/**
* @ODM\MappedSuperclass
* @ODM\HasLifecycleCallbacks
*/
#[ODM\MappedSuperclass]
#[ODM\HasLifecycleCallbacks]
abstract class BaseEventDocument
{
public function __construct()
{
}

/**
* @ODM\Field(type="string")
*
* @var string|null
*/
public $name;
#[ODM\Field(type: Type::STRING)]
public ?string $name = null;

public int $preUpdate = 0;

Expand All @@ -225,27 +220,28 @@ public function __construct()
public int $postRemove = 0;

/** @ODM\PreUpdate */
#[ODM\PreUpdate]
public function preUpdate(Event\PreUpdateEventArgs $e): void
{
$this->assertTransactionState($e);
$this->preUpdate++;
}

/** @ODM\PostPersist */
#[ODM\PostPersist]
public function postPersist(Event\LifecycleEventArgs $e): void
{
$this->assertTransactionState($e);
$this->postPersist++;
}

/** @ODM\PostUpdate */
#[ODM\PostUpdate]
public function postUpdate(Event\LifecycleEventArgs $e): void
{
$this->assertTransactionState($e);
$this->postUpdate++;
}

/** @ODM\PostRemove */
#[ODM\PostRemove]
public function postRemove(Event\LifecycleEventArgs $e): void
{
$this->assertTransactionState($e);
Expand All @@ -259,17 +255,17 @@ private function assertTransactionState(LifecycleEventArgs $e): void
}
}

/** @ODM\EmbeddedDocument */
#[ODM\EmbeddedDocument]
class EmbeddedEventDocument extends BaseEventDocument
{
}

/** @ODM\Document */
#[ODM\Document]
class RootEventDocument extends BaseEventDocument
{
/** @ODM\Id */
#[ODM\Id]
public string $id;

/** @ODM\EmbedOne(targetDocument=EmbeddedEventDocument::class) */
#[ODM\EmbedOne(targetDocument: EmbeddedEventDocument::class)]
public ?EmbeddedEventDocument $embedded;
}

0 comments on commit 406fed3

Please sign in to comment.