|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\InformationCollectionBundle\Repository; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityRepository; |
|
6
|
|
|
use eZ\Publish\API\Repository\Values\Content\Content; |
|
7
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location; |
|
8
|
|
|
use Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollection; |
|
9
|
|
|
use Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollectionAttribute; |
|
10
|
|
|
use Netgen\Bundle\InformationCollectionBundle\Value\LegacyData; |
|
11
|
|
|
|
|
12
|
|
|
class EzInfoCollectionAttributeRepository extends EntityRepository |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Get new EzInfoCollectionAttribute instance. |
|
16
|
|
|
* |
|
17
|
|
|
* @return EzInfoCollectionAttribute |
|
18
|
|
|
*/ |
|
19
|
|
|
public function getInstance() |
|
20
|
|
|
{ |
|
21
|
|
|
return new EzInfoCollectionAttribute(); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Save object. |
|
26
|
|
|
* |
|
27
|
|
|
* @param EzInfoCollectionAttribute $infoCollectionAttribute |
|
28
|
|
|
*/ |
|
29
|
|
|
public function save(EzInfoCollectionAttribute $infoCollectionAttribute) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->_em->persist($infoCollectionAttribute); |
|
32
|
|
|
$this->_em->flush($infoCollectionAttribute); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param Location $location |
|
37
|
|
|
* @param EzInfoCollection $ezInfoCollection |
|
38
|
|
|
* @param $fieldId |
|
39
|
|
|
* @param LegacyData $value |
|
40
|
|
|
* |
|
41
|
|
|
* @return EzInfoCollectionAttribute |
|
42
|
|
|
*/ |
|
43
|
|
|
public function createWithValues(Location $location, EzInfoCollection $ezInfoCollection, $fieldId, LegacyData $value) |
|
44
|
|
|
{ |
|
45
|
|
|
$ezInfoAttribute = $this->getInstance(); |
|
46
|
|
|
$ezInfoAttribute->setContentObjectId($location->getContentInfo()->id); |
|
47
|
|
|
$ezInfoAttribute->setInformationCollectionId($ezInfoCollection->getId()); |
|
48
|
|
|
$ezInfoAttribute->setContentClassAttributeId($value->getContentClassAttributeId()); |
|
49
|
|
|
$ezInfoAttribute->setContentObjectAttributeId($fieldId); |
|
50
|
|
|
$ezInfoAttribute->setDataInt($value->getDataInt()); |
|
51
|
|
|
$ezInfoAttribute->setDataFloat($value->getDataFloat()); |
|
52
|
|
|
$ezInfoAttribute->setDataText($value->getDataText()); |
|
53
|
|
|
|
|
54
|
|
|
return $ezInfoAttribute; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|