|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Webcook\Cms\CoreBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Webcook\Cms\CoreBundle\Base\BasicEntity; |
|
7
|
|
|
use Webcook\Cms\CoreBundle\Entity\PageSection; |
|
8
|
|
|
use Doctrine\ORM\Event\PreUpdateEventArgs; |
|
9
|
|
|
use Doctrine\ORM\Event\LifecycleEventArgs; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Content provider settings abstract entity. |
|
13
|
|
|
* |
|
14
|
|
|
* @ORM\MappedSuperclass |
|
15
|
|
|
* @ORM\HasLifecycleCallbacks |
|
16
|
|
|
*/ |
|
17
|
|
|
abstract class ContentProviderSettings extends BasicEntity |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @ORM\ManyToOne(targetEntity="Page") |
|
21
|
|
|
* @ORM\JoinColumn(name="page_id", referencedColumnName="id", nullable=false) |
|
22
|
|
|
*/ |
|
23
|
|
|
private $page; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @ORM\ManyToOne(targetEntity="Section") |
|
27
|
|
|
* @ORM\JoinColumn(name="section_id", referencedColumnName="id", nullable=false) |
|
28
|
|
|
*/ |
|
29
|
|
|
private $section; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Holder for order, will pass it to PageSection. |
|
33
|
|
|
*/ |
|
34
|
|
|
private $order = 0; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @ORM\PrePersist |
|
38
|
|
|
*/ |
|
39
|
22 |
|
public function savePageSection(LifecycleEventArgs $eventArgs) |
|
40
|
|
|
{ |
|
41
|
22 |
|
$em = $eventArgs->getEntityManager(); |
|
42
|
22 |
|
$contentProvider = $em->getRepository('Webcook\Cms\CoreBundle\Entity\ContentProvider')->findOneByName(get_called_class()::TAG); |
|
43
|
|
|
|
|
44
|
22 |
|
$pageSection = new PageSection(); |
|
45
|
22 |
|
$pageSection->setPage($this->page); |
|
46
|
22 |
|
$pageSection->setSection($this->section); |
|
47
|
22 |
|
$pageSection->setOrder($this->order); |
|
48
|
22 |
|
$pageSection->setContentProvider($contentProvider); |
|
49
|
|
|
|
|
50
|
22 |
|
$em->persist($pageSection); |
|
51
|
22 |
|
} |
|
52
|
|
|
|
|
53
|
5 |
|
public function getPage() |
|
54
|
|
|
{ |
|
55
|
5 |
|
return $this->page; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
22 |
|
public function setPage($page) |
|
59
|
|
|
{ |
|
60
|
22 |
|
$this->page = $page; |
|
61
|
|
|
|
|
62
|
22 |
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
22 |
|
public function setSection($section) |
|
66
|
|
|
{ |
|
67
|
22 |
|
$this->section = $section; |
|
68
|
|
|
|
|
69
|
22 |
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
5 |
|
public function getSection() |
|
73
|
|
|
{ |
|
74
|
5 |
|
return $this->section; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Gets the value of order. |
|
79
|
|
|
* |
|
80
|
|
|
* @return mixed |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getOrder() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->order; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Sets the value of order. |
|
89
|
|
|
* |
|
90
|
|
|
* @param mixed $order the order |
|
91
|
|
|
* |
|
92
|
|
|
* @return self |
|
93
|
|
|
*/ |
|
94
|
22 |
|
public function setOrder($order) |
|
95
|
|
|
{ |
|
96
|
22 |
|
$this->order = $order; |
|
97
|
|
|
|
|
98
|
22 |
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|