Skip to content

Commit

Permalink
Fixing the wrong index by setting
Browse files Browse the repository at this point in the history
+ some small refactoring
  • Loading branch information
escopecz committed Apr 12, 2023
1 parent c093cf2 commit 725a5ea
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/bundles/CampaignBundle/Entity/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;

/**
* Class Campaign.
*/
class Campaign extends FormEntity implements PublishStatusIconAttributesInterface
{
/**
Expand Down Expand Up @@ -80,9 +77,6 @@ class Campaign extends FormEntity implements PublishStatusIconAttributesInterfac
*/
private $allowRestart = false;

/**
* Constructor.
*/
public function __construct()
{
$this->events = new ArrayCollection();
Expand All @@ -107,36 +101,36 @@ public static function loadMetadata(ORM\ClassMetadata $metadata)
$builder = new ClassMetadataBuilder($metadata);

$builder->setTable('campaigns')
->setCustomRepositoryClass('Mautic\CampaignBundle\Entity\CampaignRepository');
->setCustomRepositoryClass(CampaignRepository::class);

$builder->addIdColumns();

$builder->addPublishDates();

$builder->addCategory();

$builder->createOneToMany('events', 'Event')
$builder->createOneToMany('events', Event::class)
->setIndexBy('id')
->setOrderBy(['order' => 'ASC'])
->mappedBy('campaign')
->cascadeAll()
->fetchExtraLazy()
->build();

$builder->createOneToMany('leads', 'Lead')
->setIndexBy('id')
$builder->createOneToMany('leads', Lead::class)
->setIndexBy('lead_id')
->mappedBy('campaign')
->fetchExtraLazy()
->build();

$builder->createManyToMany('lists', 'Mautic\LeadBundle\Entity\LeadList')
$builder->createManyToMany('lists', LeadList::class)
->setJoinTable('campaign_leadlist_xref')
->setIndexBy('id')
->addInverseJoinColumn('leadlist_id', 'id', false, false, 'CASCADE')
->addJoinColumn('campaign_id', 'id', true, false, 'CASCADE')
->build();

$builder->createManyToMany('forms', 'Mautic\FormBundle\Entity\Form')
$builder->createManyToMany('forms', Form::class)
->setJoinTable('campaign_form_xref')
->setIndexBy('id')
->addInverseJoinColumn('form_id', 'id', false, false, 'CASCADE')
Expand Down

0 comments on commit 725a5ea

Please sign in to comment.