Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Backend\Modules\Asaf\Domain\Products;
- use Doctrine\ORM\Mapping as ORM;
- use Backend\Core\Engine\Authentication;
- use Common\Doctrine\Entity\Meta;
- use Backend\Modules\MediaLibrary\Domain\MediaGroup\MediaGroup;
- use Backend\Modules\MediaLibrary\Domain\MediaGroup\Type as MediaGroupType;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- /**
- *
- * @ORM\Table(name="asaf_catalog")
- * @ORM\Entity(repositoryClass="Backend\Modules\Asaf\Domain\Products\ProductRepository")
- * @ORM\HasLifecycleCallbacks
- */
- class Product
- {
- /**
- * @var integer
- *
- * @ORM\Column(type="integer")
- * @ORM\Id()
- * @ORM\GeneratedValue()
- */
- private $id = 0;
- /**
- * @var int
- *
- * @ORM\Column(type="integer", name="creator_user_id")
- */
- private $creatorUserId;
- /**
- * @var string
- *
- * @ORM\Column(type="string", name="title")
- */
- private $title;
- /**
- * @var string
- *
- * @ORM\Column(type="text", nullable=true)
- */
- private $description = '';
- /**
- * @var string
- *
- * @ORM\Column(type="text", nullable=true)
- */
- private $text = '';
- /**
- * @var int
- *
- * @ORM\Column(type="integer", name="editor_user_id")
- */
- private $editorUserId;
- /**
- * @var boolean
- *
- * @ORM\Column(type="boolean", options={"default" = false})
- */
- private $active = false;
- /**
- * @var boolean
- *
- * @ORM\Column(type="boolean")
- */
- private $onMain = false;
- /**
- * @var Meta
- *
- * @ORM\OneToOne(
- * targetEntity="Common\Doctrine\Entity\Meta",
- * cascade="persist",
- * orphanRemoval=true
- * )
- * @ORM\JoinColumn(
- * name="meta_id",
- * referencedColumnName="id",
- * onDelete="cascade"
- * )
- * @ORM\Column(name="meta_id", nullable=true)
- */
- private $meta;
- /**
- * @var string
- *
- * @ORM\Column(type="string", length=255, nullable=true)
- */
- private $image = '';
- /**
- * @var MediaGroup
- *
- * @ORM\OneToOne(
- * targetEntity="Backend\Modules\MediaLibrary\Domain\MediaGroup\MediaGroup",
- * cascade="persist",
- * orphanRemoval=true
- * )
- * @ORM\JoinColumn(
- * name="mediaGroupId",
- * referencedColumnName="id",
- * onDelete="cascade"
- * )
- */
- private $mediaGroup;
- /**
- * @var Collection
- *
- * @ORM\ManyToOne(targetEntity="Backend\Modules\Asaf\Domain\Categorys\Category",mappedBy="product")
- */
- private $category;
- public function __construct(){
- $this->mediaGroup = MediaGroup::create(MediaGroupType::fromString('image'));
- $this->category = new ArrayCollection();
- }
- /**
- * @return int
- */
- public function getId(): int
- {
- return $this->id;
- }
- public function getCreatorUserId(): int
- {
- return $this->creatorUserId;
- }
- public function getEditorUserId(): int
- {
- return $this->editorUserId;
- }
- /**
- * @return bool
- */
- public function isActive(): bool
- {
- return $this->active;
- }
- /**
- * @param bool $active
- */
- public function setActive(bool $active): void
- {
- $this->active = $active;
- }
- /**
- * @return Collection $category
- */
- public function getCategory()
- {
- return $this->category;
- }
- public function setCategory(Collection $category)
- {
- $this->category = $category;
- }
- /**
- * @return bool
- */
- public function isOnMain(): bool
- {
- return $this->onMain;
- }
- /**
- * @param bool $onMain
- */
- public function setOnMain(bool $onMain): void
- {
- $this->onMain = $onMain;
- }
- /**
- * @return string
- */
- public function getTitle()
- {
- return (string)$this->title;
- }
- /**
- * @param string $title
- */
- public function setTitle(string $title): void
- {
- $this->title = $title;
- }
- /**
- * @return string
- */
- public function getDescription()
- {
- return (string)$this->description;
- }
- /**
- * @param string $description
- */
- public function setDescription(string $description): void
- {
- $this->description = $description;
- }
- /**
- * @return string
- */
- public function getText()
- {
- return (string)$this->text;
- }
- /**
- * @return Meta
- */
- public function getMeta()
- {
- return $this->meta;
- }
- /**
- * @param Meta $meta
- */
- public function setMeta(Meta $meta): void
- {
- $this->meta = $meta;
- }
- /**
- * @return string
- */
- public function getImage(): string
- {
- return $this->image;
- }
- /**
- * @param string $image
- */
- //public function setImage(string $image): void
- public function setImage($image): void
- {
- if(!$image){
- $image = '';
- }
- $this->image = $image;
- }
- /**
- * @return MediaGroup
- */
- public function getMediaGroup()
- {
- return $this->mediaGroup;
- }
- /**
- * @param MediaGroup $mediaGroup
- */
- public function setMediaGroup(MediaGroup $mediaGroup): void
- {
- $this->mediaGroup = $mediaGroup;
- }
- /**
- * @param string $text
- */
- public function setText( $text): void
- {
- $this->text = $text;
- }
- /**
- * @ORM\PrePersist
- */
- public function prePersist()
- {
- // $this->createdOn = $this->editedOn = new DateTime();
- $this->creatorUserId = $this->editorUserId = Authentication::getUser()->getUserId();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement