Browse Source

Relation Page / Merchant

master
Guillaume 4 years ago
parent
commit
2224da4c3d
2 changed files with 57 additions and 1 deletions
  1. +36
    -0
      ShopBundle/Model/Merchant.php
  2. +21
    -1
      ShopBundle/Model/Page.php

+ 36
- 0
ShopBundle/Model/Merchant.php View File

*/ */
protected $news; protected $news;


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

/** /**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", mappedBy="merchant") * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", mappedBy="merchant")
*/ */
return $this; 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[] * @return Collection|Newsletter[]
*/ */

+ 21
- 1
ShopBundle/Model/Page.php View File



namespace Lc\ShopBundle\Model; namespace Lc\ShopBundle\Model;


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


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


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

public function __toString() public function __toString()
{ {
return $this->getTitle() ; return $this->getTitle() ;


return $this; return $this;
} }

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

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

return $this;
}
} }

Loading…
Cancel
Save