Bladeren bron

Relation Page / Merchant

master
Guillaume 4 jaren geleden
bovenliggende
commit
2224da4c3d
2 gewijzigde bestanden met toevoegingen van 57 en 1 verwijderingen
  1. +36
    -0
      ShopBundle/Model/Merchant.php
  2. +21
    -1
      ShopBundle/Model/Page.php

+ 36
- 0
ShopBundle/Model/Merchant.php Bestand weergeven

@@ -56,6 +56,11 @@ abstract class Merchant extends AbstractDocumentEntity
*/
protected $news;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\PageInterface", mappedBy="merchant", orphanRemoval=true)
*/
protected $pages;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", mappedBy="merchant")
*/
@@ -279,6 +284,37 @@ abstract class Merchant extends AbstractDocumentEntity
return $this;
}

/**
* @return Collection|Page[]
*/
public function getPages(): Collection
{
return $this->pages;
}

public function addPage(Page $page): self
{
if (!$this->pages->contains($page)) {
$this->pages[] = $page;
$page->setMerchant($this);
}

return $this;
}

public function removePage(Page $page): self
{
if ($this->pages->contains($page)) {
$this->pages->removeElement($page);
// set the owning side to null (unless already changed)
if ($page->getMerchant() === $this) {
$page->setMerchant(null);
}
}

return $this;
}

/**
* @return Collection|Newsletter[]
*/

+ 21
- 1
ShopBundle/Model/Page.php Bestand weergeven

@@ -2,18 +2,26 @@

namespace Lc\ShopBundle\Model;

use App\Entity\Hub;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMerchantInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class Page extends AbstractDocumentEntity
abstract class Page extends AbstractDocumentEntity implements FilterMerchantInterface
{
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $content;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="pages")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

public function __toString()
{
return $this->getTitle() ;
@@ -30,4 +38,16 @@ abstract class Page extends AbstractDocumentEntity

return $this;
}

public function getMerchant(): ?Hub
{
return $this->merchant;
}

public function setMerchant(?Hub $merchant): self
{
$this->merchant = $merchant;

return $this;
}
}

Laden…
Annuleren
Opslaan