Skip to content
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ to copy the templates:
mkdir src/AppBundle/Newsletter
cp vendor/webfactory/newsletter-registration-bundle/app-class-templates/* src/AppBundle/Newsletter/*

If you want to implement the interfaces by yourself, you could extend the corresponding abstract classes like in the
templates above and add class level Doctrine ORM annotations (find template for them in the abstract classes). For
customizing, see the "Customizing" section below.
If you want to implement the interfaces by yourself, extend the corresponding abstract classes and add
`#[ORM\Entity(repositoryClass: MyRepo::class)]` (and any desired `#[ORM\Table(...)]` constraints) on your concrete
subclass. For customizing, see the "Customizing" section below.

In either case, configure Doctrine's interface mapping to deal with your custom entity class:

Expand Down
5 changes: 1 addition & 4 deletions src/Entity/Newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ ORM\Entity(repositoryClass="\Webfactory\NewsletterRegistrationBundle\Entity\NewsletterRepositoryInterface")
* @ ORM\Table("wfd_newsletterNewsletter")
*/
#[ORM\MappedSuperclass]
abstract class Newsletter implements NewsletterInterface
{
#[ORM\Id]
Expand Down
10 changes: 1 addition & 9 deletions src/Entity/PendingOptIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@
use Webfactory\NewsletterRegistrationBundle\Exception\EmailAddressDoesNotMatchHashOfPendingOptInException;
use Webfactory\NewsletterRegistrationBundle\StartRegistration\Type as StartRegistrationType;

/**
* @ ORM\Entity(repositoryClass="PendingOptInRepository")
* @ ORM\Table(
* uniqueConstraints={
* @ ORM\UniqueConstraint(columns={"emailAddressHash"}),
* @ ORM\UniqueConstraint(columns={"uuid"}),
* }
* )
*/
#[ORM\MappedSuperclass]
abstract class PendingOptIn implements PendingOptInInterface
{
#[ORM\Id]
Expand Down
11 changes: 1 addition & 10 deletions src/Entity/Recipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;

/**
* @ ORM\Entity()
* @ ORM\Table(
* name="wfd_newsletterRecipient",
* uniqueConstraints={
* @ ORM\UniqueConstraint(columns={"email"}),
* @ ORM\UniqueConstraint(columns={"uuid"}),
* }
* )
*/
#[ORM\MappedSuperclass]
abstract class Recipient implements RecipientInterface
{
/**
Expand Down
10 changes: 0 additions & 10 deletions tests/Entity/Dummy/PendingOptIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

namespace Webfactory\NewsletterRegistrationBundle\Tests\Entity\Dummy;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: PendingOptInRepository::class)]
class PendingOptIn extends \Webfactory\NewsletterRegistrationBundle\Entity\PendingOptIn
{
/**
* @var Collection<int, Newsletter>
*/
#[ORM\ManyToMany(targetEntity: Newsletter::class)]
#[ORM\JoinTable(
joinColumns: [new ORM\JoinColumn(referencedColumnName: 'uuid', onDelete: 'CASCADE')],
inverseJoinColumns: [new ORM\JoinColumn(onDelete: 'CASCADE')]
)]
protected Collection $newsletters;
}
10 changes: 0 additions & 10 deletions tests/Entity/Dummy/Recipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

namespace Webfactory\NewsletterRegistrationBundle\Tests\Entity\Dummy;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: RecipientRepository::class)]
class Recipient extends \Webfactory\NewsletterRegistrationBundle\Entity\Recipient
{
/**
* @var Collection<int, Newsletter>
*/
#[ORM\ManyToMany(targetEntity: Newsletter::class)]
#[ORM\JoinTable(
joinColumns: [new ORM\JoinColumn(referencedColumnName: 'uuid', onDelete: 'CASCADE')],
inverseJoinColumns: [new ORM\JoinColumn(onDelete: 'CASCADE')]
)]
protected Collection $newsletters;
}
5 changes: 5 additions & 0 deletions tests/Fixtures/config/doctrine.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Webfactory\NewsletterRegistrationBundle\Entity\NewsletterInterface;
use Webfactory\NewsletterRegistrationBundle\Tests\Entity\Dummy\Newsletter;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('doctrine', [
Expand All @@ -10,6 +12,9 @@
],
'orm' => [
'auto_generate_proxy_classes' => true,
'resolve_target_entities' => [
NewsletterInterface::class => Newsletter::class,
],
'mappings' => [
'BundleEntities' => [
'is_bundle' => false,
Expand Down
Loading