src/CmsBundle/Entity/DirectoryItem.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\CmsBundle\Entity;
  3. use App\CasinoBundle\Entity\BonusAmount;
  4. use App\CasinoBundle\Entity\BonusCategory;
  5. use App\CasinoBundle\Entity\Casino;
  6. use App\CasinoBundle\Entity\CasinoCategory;
  7. use App\CasinoBundle\Entity\City;
  8. use App\CasinoBundle\Entity\Country;
  9. use App\CasinoBundle\Entity\Currency;
  10. use App\CasinoBundle\Entity\GameType;
  11. use App\CasinoBundle\Entity\PaymentMethod;
  12. use App\CasinoBundle\Entity\Slot;
  13. use App\CasinoBundle\Entity\Software;
  14. use App\CasinoBundle\Entity\State;
  15. use App\CmsBundle\Enum\DirectoryType;
  16. use App\CasinoBundle\Entity\MinDeposit;
  17. use Doctrine\ORM\Mapping as ORM;
  18. /**
  19.  * @ORM\Entity(
  20.  *     repositoryClass="App\CmsBundle\Repository\DirectoryItemRepository"
  21.  * )
  22.  * @ORM\Table(
  23.  *     name="directory_item",
  24.  *     indexes={
  25.  *         @ORM\Index(name="directory_item_index", columns={"directory_id"})
  26.  *     }
  27.  * )
  28.  */
  29. class DirectoryItem
  30. {
  31.     use IdTrait;
  32.     /**
  33.      * @ORM\OneToOne(targetEntity="App\CmsBundle\Entity\Page", mappedBy="directoryItem")
  34.      * @ORM\JoinColumn(name="page_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  35.      */
  36.     private $page;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity="App\CmsBundle\Entity\Directory", inversedBy="directoryItems")
  39.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  40.      */
  41.     private $directory;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Casino")
  44.      * @ORM\JoinColumn(nullable=true)
  45.      */
  46.     private $casino;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Slot")
  49.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  50.      */
  51.     private $slot;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Software", inversedBy="directoryItems")
  54.      * @ORM\JoinColumn(nullable=true)
  55.      */
  56.     private $software;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\PaymentMethod")
  59.      * @ORM\JoinColumn(nullable=true)
  60.      */
  61.     private $paymentMethod;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Country")
  64.      * @ORM\JoinColumn(nullable=true)
  65.      */
  66.     private $country;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Currency")
  69.      * @ORM\JoinColumn(nullable=true)
  70.      */
  71.     private $currency;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\GameType")
  74.      * @ORM\JoinColumn(nullable=true)
  75.      */
  76.     private $gameType;
  77.     /**
  78.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\City")
  79.      * @ORM\JoinColumn(nullable=true)
  80.      */
  81.     private $city;
  82.     /**
  83.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\State")
  84.      * @ORM\JoinColumn(nullable=true)
  85.      */
  86.     private $state;
  87.     /**
  88.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\BonusAmount")
  89.      * @ORM\JoinColumn(nullable=true)
  90.      */
  91.     private $bonusAmount;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\MinDeposit")
  94.      * @ORM\JoinColumn(nullable=true)
  95.      */
  96.     private $minDeposit;
  97.     
  98.     /**
  99.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\BonusCategory")
  100.      * @ORM\JoinColumn(nullable=true)
  101.      */
  102.     private $bonusCategory;
  103.     /**
  104.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\CasinoCategory")
  105.      * @ORM\JoinColumn(nullable=true)
  106.      */
  107.     private $casinoCategory;
  108.     public function __construct()
  109.     {
  110.     }
  111.     /**
  112.      * @return Directory|null
  113.      */
  114.     public function getDirectory(): ?Directory
  115.     {
  116.         return $this->directory;
  117.     }
  118.     /**
  119.      * @param Directory|null $directory
  120.      * @return $this
  121.      */
  122.     public function setDirectory(?Directory $directory null): self
  123.     {
  124.         $this->directory $directory;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Casino|null
  129.      */
  130.     public function getCasino(): ?Casino
  131.     {
  132.         return $this->casino;
  133.     }
  134.     /**
  135.      * @param Casino|null $casino
  136.      * @return $this
  137.      */
  138.     public function setCasino(?Casino $casino null): self
  139.     {
  140.         $this->casino $casino;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Slot|null
  145.      */
  146.     public function getSlot(): ?Slot
  147.     {
  148.         return $this->slot;
  149.     }
  150.     /**
  151.      * @param Slot|null $slot
  152.      * @return $this
  153.      */
  154.     public function setSlot(?Slot $slot null): self
  155.     {
  156.         $this->slot $slot;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Software|null
  161.      */
  162.     public function getSoftware(): ?Software
  163.     {
  164.         return $this->software;
  165.     }
  166.     /**
  167.      * @param Software|null $software
  168.      * @return $this
  169.      */
  170.     public function setSoftware(?Software $software null): self
  171.     {
  172.         $this->software $software;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return PaymentMethod|null
  177.      */
  178.     public function getPaymentMethod(): ?PaymentMethod
  179.     {
  180.         return $this->paymentMethod;
  181.     }
  182.     /**
  183.      * @param PaymentMethod|null $paymentMethod
  184.      * @return $this
  185.      */
  186.     public function setPaymentMethod(?PaymentMethod $paymentMethod null): self
  187.     {
  188.         $this->paymentMethod $paymentMethod;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Country|null
  193.      */
  194.     public function getCountry(): ?Country
  195.     {
  196.         return $this->country;
  197.     }
  198.     /**
  199.      * @param Country|null $country
  200.      * @return $this
  201.      */
  202.     public function setCountry(?Country $country null): self
  203.     {
  204.         $this->country $country;
  205.         return $this;
  206.     }
  207.     /**
  208.      * @return Currency|null
  209.      */
  210.     public function getCurrency(): ?Currency
  211.     {
  212.         return $this->currency;
  213.     }
  214.     /**
  215.      * @param Currency|null $currency
  216.      * @return $this
  217.      */
  218.     public function setCurrency(?Currency $currency null): self
  219.     {
  220.         $this->currency $currency;
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return GameType|null
  225.      */
  226.     public function getGameType(): ?GameType
  227.     {
  228.         return $this->gameType;
  229.     }
  230.     /**
  231.      * @param GameType|null $gameType
  232.      * @return $this
  233.      */
  234.     public function setGameType(?GameType $gameType null): self
  235.     {
  236.         $this->gameType $gameType;
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return BonusAmount|null
  241.      */
  242.     public function getBonusAmount(): ?BonusAmount
  243.     {
  244.         return $this->bonusAmount;
  245.     }
  246.     /**
  247.      * @param BonusAmount|null $bonusAmount
  248.      * @return $this
  249.      */
  250.     public function setBonusAmount(?BonusAmount $bonusAmount null): self
  251.     {
  252.         $this->bonusAmount $bonusAmount;
  253.         return $this;
  254.     }
  255.     /**
  256.      * @return BonusCategory|null
  257.      */
  258.     public function getBonusCategory(): ?BonusCategory
  259.     {
  260.         return $this->bonusCategory;
  261.     }
  262.     /**
  263.      * @param BonusCategory|null $bonusCategory
  264.      * @return $this
  265.      */
  266.     public function setBonusCategory(?BonusCategory $bonusCategory null): self
  267.     {
  268.         $this->bonusCategory $bonusCategory;
  269.         return $this;
  270.     }
  271.     /**
  272.      * @return CasinoCategory|null
  273.      */
  274.     public function getCasinoCategory(): ?CasinoCategory
  275.     {
  276.         return $this->casinoCategory;
  277.     }
  278.     /**
  279.      * @param CasinoCategory|null $casinoCategory
  280.      * @return $this
  281.      */
  282.     public function setCasinoCategory(?CasinoCategory $casinoCategory null): self
  283.     {
  284.         $this->casinoCategory $casinoCategory;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return City|null
  289.      */
  290.     public function getCity(): ?City
  291.     {
  292.         return $this->city;
  293.     }
  294.     /**
  295.      * @param City|null $city
  296.      * @return $this
  297.      */
  298.     public function setCity(?City $city null): self
  299.     {
  300.         $this->city $city;
  301.         return $this;
  302.     }
  303.     /**
  304.      * @return State|null
  305.      */
  306.     public function getState(): ?State
  307.     {
  308.         return $this->state;
  309.     }
  310.     /**
  311.      * @param State|null $state
  312.      * @return $this
  313.      */
  314.     public function setState(?State $state null): self
  315.     {
  316.         $this->state $state;
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return Page|null
  321.      */
  322.     public function getPage(): ?Page
  323.     {
  324.         return $this->page;
  325.     }
  326.     /**
  327.      * @param Page|null $page
  328.      * @return $this
  329.      */
  330.     public function setPage(?Page $page null): self
  331.     {
  332.         $this->page $page;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return MinDeposit|null
  337.      */
  338.     public function getMinDeposit(): ?MinDeposit
  339.     {
  340.         return $this->minDeposit;
  341.     }
  342.     /**
  343.      * @param MinDeposit|null $minDeposit
  344.      * @return $this
  345.      */
  346.     public function setMinDeposit(?MinDeposit $minDeposit null): self
  347.     {
  348.         $this->minDeposit $minDeposit;
  349.         return $this;
  350.     }
  351.     /**
  352.      * @return int|null
  353.      */
  354.     public function getType(): ?int
  355.     {
  356.         if ($this->getCasino() != null)        return DirectoryType::CASINO;
  357.         if ($this->getSlot() != null)          return DirectoryType::SLOT;
  358.         if ($this->getSoftware() != null)      return DirectoryType::SOFTWARE;
  359.         if ($this->getPaymentMethod() != null) return DirectoryType::PAYMENT_METHOD;
  360.         if ($this->getCountry() != null)       return DirectoryType::COUNTRY;
  361.         if ($this->getGameType() != null)      return DirectoryType::GAME_TYPE;
  362.         if ($this->getBonusAmount() != null)   return DirectoryType::BONUS_AMOUNT;
  363.         if ($this->getState() != null)         return DirectoryType::STATE;
  364.         if ($this->getCity() != null)          return DirectoryType::CITY;
  365.         if ($this->getCurrency() != null)      return DirectoryType::CURRENCY;
  366.         if ($this->getMinDeposit() != null)    return DirectoryType::MIN_DEPOSIT;
  367.         return null;
  368.     }
  369.     /**
  370.      * @return string|null
  371.      */
  372.     public function getSlug(): ?string
  373.     {
  374.         return match ($this->getType()) {
  375.             DirectoryType::CASINO => $this->getCasino()->getDomain(),
  376.             DirectoryType::SLOT => $this->getSlot()->getSlug(),
  377.             DirectoryType::SOFTWARE => $this->getSoftware()->getSlug(),
  378.             DirectoryType::PAYMENT_METHOD => $this->getPaymentMethod()->getSlug(),
  379.             DirectoryType::COUNTRY => $this->getCountry()->getSlug(),
  380.             DirectoryType::GAME_TYPE => $this->getGameType()->getSlug(),
  381.             DirectoryType::BONUS_AMOUNT => $this->getBonusAmount()->getSlug(),
  382.             DirectoryType::STATE => $this->getState()->getSlug(),
  383.             DirectoryType::CITY => $this->getCity()->getSlug(),
  384.             DirectoryType::CURRENCY => $this->getCurrency()->getSlug(),
  385.             DirectoryType::MIN_DEPOSIT => $this->getMinDeposit()->getSlug(),
  386.             default => null,
  387.         };
  388.     }
  389. }