Completed
Push — v2 ( 78434f...807831 )
by Daniel
04:02
created

AbstractPageData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
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 Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Collection;
18
use Doctrine\ORM\Mapping as ORM;
19
20
/**
21
 * @author Daniel West <[email protected]>
22
 * @ORM\Entity
23
 * @ORM\Table(name="page_data")
24
 * @ORM\InheritanceType("SINGLE_TABLE")
25
 * @ORM\DiscriminatorColumn(name="dtype", type="string")
26
 * @ORM\AssociationOverrides({
27
 *     @ORM\AssociationOverride(name="routes", inversedBy="pageData")
28
 * })
29
 */
30
abstract class AbstractPageData extends AbstractPage implements PageDataInterface
31
{
32
    /*
33
     * Extend this class for pages where the same page template should be used for multiple entities.
34
     * A good example is an article page. You would create an Article entity in your project that extends this class.
35
     * That article can then be accessed via a route on the API and the data in this class will override whatever is in the template.
36
     * You can create a ComponentPopulator service to use the data provided here to populate the template. You could update text
37
     * within entities with interpolation, or add new components on the fly depending on what you have defined here.
38
     */
39
40
    /**
41
     * @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Core\PageTemplate")
42
     * @ORM\JoinColumn(nullable=false)
43
     *
44
     * @var PageTemplate[]|Collection
45
     */
46
    public Collection $pageTemplate;
47
48
    public function __construct()
49
    {
50
        parent::__construct();
51
        $this->pageTemplate = new ArrayCollection();
52
    }
53
}
54