Skip to content
Snippets Groups Projects
Category.php 2.37 KiB
<?php
/*
 * This file is part of the "RicoDynamicFAQ" plugin for shopware.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * (c) 2019 Wolf Utz <utz@riconet.de>, Hees riconet GmbH
 */

declare(strict_types=1);

namespace RicoDynamicFAQ\Models;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Shopware\Components\Model\ModelEntity;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class Category.
 *
 * @ORM\Entity(repositoryClass="RicoDynamicFAQ\Repository\CategoryRepository")
 * @ORM\Table(name="s_rico_dynamic_faq_category", options={"collate"="utf8_unicode_ci"})
 */
class Category extends ModelEntity
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id = 0;

    /**
     * @var string
     *
     * @ORM\Column()
     */
    protected $name = '';

    /**
     * @var Category
     *
     * @ORM\ManyToOne(targetEntity="RicoDynamicFAQ\Models\Category", inversedBy="children")
     * @ORM\JoinColumn(name="parent", referencedColumnName="id")
     */
    protected $parent;

    /**
     * @var ArrayCollection
     *
     * @ORM\OneToMany(targetEntity="RicoDynamicFAQ\Models\Category", mappedBy="parent")
     */
    protected $children;

    /**
     * Category constructor.
     */
    public function __construct()
    {
        $this->children = new ArrayCollection();
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     */
    public function setName(string $name)
    {
        $this->name = $name;
    }

    /**
     * @return Category
     */
    public function getParent(): Category
    {
        return $this->parent;
    }

    /**
     * @param Category $parent
     */
    public function setParent(Category $parent)
    {
        $this->parent = $parent;
    }

    /**
     * @return Collection
     */
    public function getChildren(): Collection
    {
        return $this->children;
    }

    /**
     * @param Collection $children
     */
    public function setChildren(Collection $children)
    {
        $this->children = $children;
    }
}