src/Entity/Category.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Sale;
  4. use App\Entity\Vehicle;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
  10.  *
  11.  * @ORM\Table(
  12.  *     name="vehicle_category",
  13.  *     indexes={
  14.  *
  15.  *         @ORM\Index(columns={"rank"})
  16.  *     }
  17.  * )
  18.  */
  19. class Category implements \Stringable
  20. {
  21.     /**
  22.      * @ORM\Id
  23.      *
  24.      * @ORM\Column(type="bigint")
  25.      *
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     protected $id;
  29.     /**
  30.      * @ORM\Column(type="string")
  31.      */
  32.     protected $name_canonical;
  33.     public function __construct(/**
  34.      * @ORM\Column(type="string")
  35.      */
  36.         protected $name/**
  37.      * @ORM\Column(type="integer")
  38.      */
  39.         protected $rank/**
  40.      * @ORM\Column(name="rank_results", type="integer")
  41.      */
  42.         protected $rankResults)
  43.     {
  44.         $this->name_canonical self::getCanonicalStr($this->name);
  45.     }
  46.     public function __toString(): string
  47.     {
  48.         return (string) $this->getName();
  49.     }
  50.     public static function getCanonicalStr($str)
  51.     {
  52.         $a = ['À''Á''Â''Ã''Ä''Å''Æ''Ç''È''É''Ê''Ë''Ì''Í''Î''Ï''Ð''Ñ''Ò''Ó''Ô''Õ''Ö''Ø''Ù''Ú''Û''Ü''Ý''ß''à''á''â''ã''ä''å''æ''ç''è''é''ê''ë''ì''í''î''ï''ñ''ò''ó''ô''õ''ö''ø''ù''ú''û''ü''ý''ÿ''A''a''A''a''A''a''C''c''C''c''C''c''C''c''D''d''Ð''d''E''e''E''e''E''e''E''e''E''e''G''g''G''g''G''g''G''g''H''h''H''h''I''i''I''i''I''i''I''i''I''i''?''?''J''j''K''k''L''l''L''l''L''l''?''?''L''l''N''n''N''n''N''n''?''O''o''O''o''O''o''Œ''œ''R''r''R''r''R''r''S''s''S''s''S''s''Š''š''T''t''T''t''T''t''U''u''U''u''U''u''U''u''U''u''U''u''W''w''Y''y''Ÿ''Z''z''Z''z''Ž''ž''?''ƒ''O''o''U''u''A''a''I''i''O''o''U''u''U''u''U''u''U''u''U''u''?''?''?''?''?''?'];
  53.         $b = ['A''A''A''A''A''A''AE''C''E''E''E''E''I''I''I''I''D''N''O''O''O''O''O''O''U''U''U''U''Y''s''a''a''a''a''a''a''ae''c''e''e''e''e''i''i''i''i''n''o''o''o''o''o''o''u''u''u''u''y''y''A''a''A''a''A''a''C''c''C''c''C''c''C''c''D''d''D''d''E''e''E''e''E''e''E''e''E''e''G''g''G''g''G''g''G''g''H''h''H''h''I''i''I''i''I''i''I''i''I''i''IJ''ij''J''j''K''k''L''l''L''l''L''l''L''l''l''l''N''n''N''n''N''n''n''O''o''O''o''O''o''OE''oe''R''r''R''r''R''r''S''s''S''s''S''s''S''s''T''t''T''t''T''t''U''u''U''u''U''u''U''u''U''u''U''u''W''w''Y''y''Y''Z''z''Z''z''Z''z''s''f''O''o''U''u''A''a''I''i''O''o''U''u''U''u''U''u''U''u''U''u''A''a''AE''ae''O''o'];
  54.         return strtolower(preg_replace(['/[^a-zA-Z0-9 -]/''/[ -]+/''/^-|-$/'], [''''''], str_replace($a$b$str)));
  55.     }
  56.     public function getId()
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function setId($id): void
  61.     {
  62.         $this->id $id;
  63.     }
  64.     public function getName()
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName($name)
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getNameCanonical()
  74.     {
  75.         return $this->name_canonical;
  76.     }
  77.     public function setNameCanonical($name_canonical)
  78.     {
  79.         $this->name_canonical $name_canonical;
  80.         return $this;
  81.     }
  82.     public function getRank()
  83.     {
  84.         return $this->rank;
  85.     }
  86.     public function setRank($rank)
  87.     {
  88.         $this->rank $rank;
  89.         return $this;
  90.     }
  91.     public function getRankResults()
  92.     {
  93.         return $this->rankResults;
  94.     }
  95.     public function setRankResults($rankResults)
  96.     {
  97.         $this->rankResults $rankResults;
  98.         return $this;
  99.     }
  100. }