src/Submarine/RedirectsBundle/Entity/Redirect.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Submarine\RedirectsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity()
  6.  * @ORM\Table(name="submarine_redirects_redirects", indexes={@ORM\Index(name="original_url_idx", columns={"original_url"})})
  7.  */
  8. class Redirect
  9. {
  10.     /**
  11.      * @var int
  12.      *
  13.      * @ORM\Column(name="id", type="integer")
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue(strategy="AUTO")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @var string
  20.      *
  21.      * @ORM\Column(name="original_url", type="string")
  22.      */
  23.     private $originalUrl '';
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="redirect_url", type="string")
  28.      */
  29.     private $redirectUrl '';
  30.     /**
  31.      * @var int
  32.      *
  33.      * @ORM\Column(name="code", type="smallint")
  34.      */
  35.     private $code 301;
  36.     /**
  37.      * @var bool
  38.      *
  39.      * @ORM\Column(name="active", type="boolean")
  40.      */
  41.     private $active false;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="comment", type="string")
  46.      */
  47.     private $comment '';
  48.     /**
  49.      * @var \DateTime
  50.      *
  51.      * @ORM\Column(name="created_at", type="datetime")
  52.      */
  53.     private $createdAt;
  54.     /**
  55.      * @var \DateTime
  56.      *
  57.      * @ORM\Column(name="updated_at", type="datetime")
  58.      */
  59.     private $updatedAt;
  60.     /**
  61.      * @param string $originalUrl
  62.      * @param int $code
  63.      * @param int $counter
  64.      */
  65.     public function __construct(string $originalUrl ''int $code 301)
  66.     {
  67.         $this->originalUrl $originalUrl;
  68.         $this->code $code;
  69.         $this->createdAt = new \DateTime();
  70.         $this->updatedAt = clone $this->createdAt;
  71.     }
  72.     /**
  73.      * @return int
  74.      */
  75.     public function getId(): int
  76.     {
  77.         return $this->id;
  78.     }
  79.     /**
  80.      * @return string
  81.      */
  82.     public function getOriginalUrl(): string
  83.     {
  84.         return $this->originalUrl;
  85.     }
  86.     /**
  87.      * @param string $originalUrl
  88.      */
  89.     public function setOriginalUrl(string $originalUrl)
  90.     {
  91.         $this->originalUrl $originalUrl;
  92.     }
  93.     /**
  94.      * @return string
  95.      */
  96.     public function getRedirectUrl(): string
  97.     {
  98.         return $this->redirectUrl;
  99.     }
  100.     /**
  101.      * @param string $redirectUrl
  102.      */
  103.     public function setRedirectUrl(string $redirectUrl)
  104.     {
  105.         $this->redirectUrl $redirectUrl;
  106.     }
  107.     /**
  108.      * @return int
  109.      */
  110.     public function getCode(): int
  111.     {
  112.         return $this->code;
  113.     }
  114.     /**
  115.      * @param int $code
  116.      */
  117.     public function setCode(int $code)
  118.     {
  119.         $this->code $code;
  120.         $this->updatedAt = new \DateTime();
  121.     }
  122.     /**
  123.      * @return bool
  124.      */
  125.     public function isActive(): bool
  126.     {
  127.         return $this->active;
  128.     }
  129.     /**
  130.      * @param bool $active
  131.      */
  132.     public function setActive(bool $active)
  133.     {
  134.         $this->active $active;
  135.         $this->updatedAt = new \DateTime();
  136.     }
  137.     /**
  138.      * @return string
  139.      */
  140.     public function getComment(): string
  141.     {
  142.         return $this->comment;
  143.     }
  144.     /**
  145.      * @param string $comment
  146.      */
  147.     public function setComment(string $comment)
  148.     {
  149.         $this->comment $comment;
  150.         $this->updatedAt = new \DateTime();
  151.     }
  152.     /**
  153.      * @return \DateTime
  154.      */
  155.     public function getCreatedAt(): \DateTime
  156.     {
  157.         return $this->createdAt;
  158.     }
  159.     /**
  160.      * @return \DateTime
  161.      */
  162.     public function getUpdatedAt(): \DateTime
  163.     {
  164.         return $this->updatedAt;
  165.     }
  166. }