1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Silverback API Component Bundle Project |
5
|
|
|
* |
6
|
|
|
* (c) Daniel West <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Core; |
15
|
|
|
|
16
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
17
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
18
|
|
|
use Doctrine\Common\Collections\Collection; |
19
|
|
|
use Doctrine\ORM\Mapping as ORM; |
20
|
|
|
use Silverback\ApiComponentBundle\Entity\Utility\IdTrait; |
21
|
|
|
use Silverback\ApiComponentBundle\Entity\Utility\TimestampedInterface; |
22
|
|
|
use Silverback\ApiComponentBundle\Entity\Utility\TimestampedTrait; |
23
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @author Daniel West <[email protected]> |
27
|
|
|
* @ApiResource( |
28
|
|
|
* collectionOperations={ |
29
|
|
|
* "get"={"security"="is_granted('ROLE_SUPER_ADMIN')"}, |
30
|
|
|
* "post" |
31
|
|
|
* } |
32
|
|
|
* ) |
33
|
|
|
* @ORM\Entity(repositoryClass="Silverback\ApiComponentBundle\Repository\Core\RouteRepository") |
34
|
|
|
* @Assert\Expression( |
35
|
|
|
* "!(this.pageTemplate == null & this.pageData == null) & !(this.pageTemplate != null & this.pageData != null)", |
36
|
|
|
* message="Please specify either pageTemplate or pageData, not both." |
37
|
|
|
* ) |
38
|
|
|
*/ |
39
|
|
|
class Route implements TimestampedInterface |
40
|
|
|
{ |
41
|
|
|
use IdTrait; |
42
|
|
|
use TimestampedTrait; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @ORM\Column(unique=true) |
46
|
|
|
* @Assert\NotNull() |
47
|
|
|
*/ |
48
|
|
|
public string $route; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @ORM\Column(unique=true) |
52
|
|
|
* @Assert\NotNull() |
53
|
|
|
*/ |
54
|
|
|
public string $name; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Core\Route", inversedBy="redirectedFrom") |
58
|
|
|
* @ORM\JoinColumn(name="redirect", referencedColumnName="id", onDelete="SET NULL") |
59
|
|
|
*/ |
60
|
|
|
public ?Route $redirect = null; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @ORM\OneToMany(targetEntity="Silverback\ApiComponentBundle\Entity\Core\Route", mappedBy="redirect") |
64
|
|
|
*/ |
65
|
|
|
public Collection $redirectedFrom; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ORM\OneToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Core\PageTemplate", mappedBy="route") |
69
|
|
|
* @ORM\JoinColumn(onDelete="SET NULL", nullable=true) |
70
|
|
|
*/ |
71
|
|
|
public ?PageTemplate $pageTemplate = null; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @ORM\OneToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Core\AbstractPageData", mappedBy="route") |
75
|
|
|
* @ORM\JoinColumn(onDelete="SET NULL", nullable=true) |
76
|
|
|
*/ |
77
|
|
|
public ?AbstractPageData $pageData = null; |
78
|
|
|
|
79
|
1 |
|
public function __construct() |
80
|
|
|
{ |
81
|
1 |
|
$this->setId(); |
82
|
1 |
|
$this->redirectedFrom = new ArrayCollection(); |
83
|
1 |
|
} |
84
|
|
|
} |
85
|
|
|
|