|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\InformationCollectionBundle\Repository; |
|
4
|
|
|
|
|
5
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location; |
|
6
|
|
|
use eZ\Publish\API\Repository\Values\User\User; |
|
7
|
|
|
use Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollection; |
|
8
|
|
|
use Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollectionAttribute; |
|
9
|
|
|
use Netgen\Bundle\InformationCollectionBundle\Value\LegacyData; |
|
10
|
|
|
|
|
11
|
|
|
class RepositoryAggregate |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var EzInfoCollectionRepository |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $infoCollectionRepository; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var EzInfoCollectionAttributeRepository |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $infoCollectionAttributeRepository; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* RepositoryAggregate constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @param EzInfoCollectionRepository $infoCollectionRepository |
|
27
|
|
|
* @param EzInfoCollectionAttributeRepository $infoCollectionAttributeRepository |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct( |
|
30
|
|
|
EzInfoCollectionRepository $infoCollectionRepository, |
|
31
|
|
|
EzInfoCollectionAttributeRepository $infoCollectionAttributeRepository |
|
32
|
|
|
) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->infoCollectionRepository = $infoCollectionRepository; |
|
35
|
|
|
$this->infoCollectionAttributeRepository = $infoCollectionAttributeRepository; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Creates EzInfoCollection instance |
|
40
|
|
|
* |
|
41
|
|
|
* @param Location $location |
|
42
|
|
|
* @param User $currentUser |
|
43
|
|
|
* |
|
44
|
|
|
* @return \Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollection |
|
45
|
|
|
*/ |
|
46
|
|
|
public function createMain(Location $location, User $currentUser) |
|
47
|
|
|
{ |
|
48
|
|
|
$main = $this->infoCollectionRepository->createWithValues($location, $currentUser); |
|
49
|
|
|
|
|
50
|
|
|
$this->infoCollectionRepository->save($main); |
|
51
|
|
|
|
|
52
|
|
|
return $main; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Creates EzInfoCollectionAttribute instance |
|
57
|
|
|
* |
|
58
|
|
|
* @param Location $location |
|
59
|
|
|
* @param EzInfoCollection $ezInfoCollection |
|
60
|
|
|
* @param int $fieldId |
|
61
|
|
|
* @param LegacyData $value |
|
62
|
|
|
* |
|
63
|
|
|
* @return \Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollectionAttribute |
|
64
|
|
|
*/ |
|
65
|
|
|
public function createChild(Location $location, EzInfoCollection $ezInfoCollection, $fieldId, LegacyData $value) |
|
66
|
|
|
{ |
|
67
|
|
|
$child = $this->infoCollectionAttributeRepository |
|
68
|
|
|
->createWithValues($location, $ezInfoCollection, $fieldId, $value); |
|
69
|
|
|
|
|
70
|
|
|
$this->infoCollectionAttributeRepository->save($child); |
|
71
|
|
|
|
|
72
|
|
|
return $child; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|