1
|
|
|
<?php |
2
|
|
|
/*************************************************************************************/ |
3
|
|
|
/* This file is part of the Thelia package. */ |
4
|
|
|
/* */ |
5
|
|
|
/* Copyright (c) OpenStudio */ |
6
|
|
|
/* email : [email protected] */ |
7
|
|
|
/* web : http://www.thelia.net */ |
8
|
|
|
/* */ |
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
10
|
|
|
/* file that was distributed with this source code. */ |
11
|
|
|
/*************************************************************************************/ |
12
|
|
|
/*************************************************************************************/ |
13
|
|
|
|
14
|
|
|
namespace Dealer\Loop; |
15
|
|
|
|
16
|
|
|
use Dealer\Model\Base\DealerContactInfoQuery; |
17
|
|
|
use Dealer\Model\DealerContactInfo; |
18
|
|
|
use Dealer\Model\Map\DealerContactInfoTableMap; |
19
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
20
|
|
|
use Thelia\Core\Template\Element\BaseI18nLoop; |
21
|
|
|
use Thelia\Core\Template\Element\LoopResult; |
22
|
|
|
use Thelia\Core\Template\Element\LoopResultRow; |
23
|
|
|
use Thelia\Core\Template\Element\PropelSearchLoopInterface; |
24
|
|
|
use Thelia\Core\Template\Loop\Argument\Argument; |
25
|
|
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class ContactInfoLoop |
29
|
|
|
* @package Dealer\Loop |
30
|
|
|
*/ |
31
|
|
|
class ContactInfoLoop extends BaseI18nLoop implements PropelSearchLoopInterface |
32
|
|
|
{ |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param LoopResult $loopResult |
36
|
|
|
* |
37
|
|
|
* @return LoopResult |
38
|
|
|
*/ |
39
|
|
|
public function parseResults(LoopResult $loopResult) |
40
|
|
|
{ |
41
|
|
|
/** @var DealerContactInfo $contact */ |
42
|
|
|
foreach ($loopResult->getResultDataCollection() as $contact) { |
43
|
|
|
$loopResultRow = new LoopResultRow($contact); |
44
|
|
|
|
45
|
|
|
$loopResultRow |
46
|
|
|
->set('ID', $contact->getId()) |
47
|
|
|
->set('CONTACT_ID', $contact->getContactId()) |
48
|
|
|
->set('CONTACT_TYPE', $contact->getContactType()) |
49
|
|
|
->set('CONTACT_TYPE_ID', $contact->getContactTypeId()); |
50
|
|
|
|
51
|
|
|
if ($contact->hasVirtualColumn('i18n_VALUE')) { |
52
|
|
|
$loopResultRow->set("VALUE", $contact->getVirtualColumn('i18n_VALUE')); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$loopResult->addRow($loopResultRow); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return $loopResult; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Definition of loop arguments |
63
|
|
|
* |
64
|
|
|
* example : |
65
|
|
|
* |
66
|
|
|
* public function getArgDefinitions() |
67
|
|
|
* { |
68
|
|
|
* return new ArgumentCollection( |
69
|
|
|
* |
70
|
|
|
* Argument::createIntListTypeArgument('id'), |
71
|
|
|
* new Argument( |
72
|
|
|
* 'ref', |
73
|
|
|
* new TypeCollection( |
74
|
|
|
* new Type\AlphaNumStringListType() |
75
|
|
|
* ) |
76
|
|
|
* ), |
77
|
|
|
* Argument::createIntListTypeArgument('category'), |
78
|
|
|
* Argument::createBooleanTypeArgument('new'), |
79
|
|
|
* ... |
80
|
|
|
* ); |
81
|
|
|
* } |
82
|
|
|
* |
83
|
|
|
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection |
84
|
|
|
*/ |
85
|
|
|
protected function getArgDefinitions() |
86
|
|
|
{ |
87
|
|
|
return new ArgumentCollection( |
88
|
|
|
Argument::createIntListTypeArgument('id'), |
89
|
|
|
Argument::createIntListTypeArgument('contact_id'), |
90
|
|
|
Argument::createEnumListTypeArgument('contact_type', DealerContactInfoTableMap::getValueSet(DealerContactInfoTableMap::CONTACT_TYPE), null), |
91
|
|
|
Argument::createEnumListTypeArgument('order', [ |
92
|
|
|
'id', |
93
|
|
|
'id-reverse', |
94
|
|
|
'value', |
95
|
|
|
'value-reverse', |
96
|
|
|
], 'id') |
97
|
|
|
|
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* this method returns a Propel ModelCriteria |
103
|
|
|
* |
104
|
|
|
* @return \Propel\Runtime\ActiveQuery\ModelCriteria |
105
|
|
|
*/ |
106
|
|
|
public function buildModelCriteria() |
107
|
|
|
{ |
108
|
|
|
$query = DealerContactInfoQuery::create(); |
109
|
|
|
|
110
|
|
|
$this->configureI18nProcessing( |
111
|
|
|
$query, |
112
|
|
|
[ |
113
|
|
|
'VALUE', |
114
|
|
|
], |
115
|
|
|
null, |
116
|
|
|
'ID', |
117
|
|
|
$this->getForceReturn() |
118
|
|
|
); |
119
|
|
|
|
120
|
|
|
if ($id = $this->getId()) { |
121
|
|
|
$query->filterById($id); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
if (null != $type = $this->getContactType()) { |
125
|
|
|
$query->filterByContactType($type); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
if ($contact_id = $this->getContactId()) { |
129
|
|
|
$query->filterByContactId($contact_id); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
foreach ($this->getOrder() as $order) { |
133
|
|
|
switch ($order) { |
134
|
|
|
case 'id': |
135
|
|
|
$query->orderById(); |
136
|
|
|
break; |
137
|
|
|
case 'id-reverse': |
138
|
|
|
$query->orderById(Criteria::DESC); |
139
|
|
|
break; |
140
|
|
|
case 'value': |
141
|
|
|
$query->orderByValue(); |
142
|
|
|
break; |
143
|
|
|
case 'value-reverse': |
144
|
|
|
$query->orderByValue(Criteria::DESC); |
145
|
|
|
break; |
146
|
|
|
default: |
147
|
|
|
break; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
return $query; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|