Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 5313c64

Browse files
authored
Merge pull request #937 from stwe/revert-914-philippemilink-feature-other-column-as-source
Revert "Add attributes mapped, is_association and data_source"
2 parents 661438c + ca200d3 commit 5313c64

13 files changed

+93
-267
lines changed

Diff for: Datatable/Column/AbstractColumn.php

+4-165
Original file line numberDiff line numberDiff line change
@@ -296,39 +296,6 @@ abstract class AbstractColumn implements ColumnInterface
296296
* @var bool
297297
*/
298298
protected $sentInResponse;
299-
300-
/**
301-
* If this column displays the total of its cells in its head
302-
* Default: false.
303-
*
304-
* @var bool
305-
*/
306-
protected $computeTotal;
307-
308-
/**
309-
* Contains the eventually computed total of the column.
310-
*
311-
* @var mixed
312-
*/
313-
protected $total;
314-
315-
/**
316-
* If the column represents a real column in the database.
317-
*
318-
* @var bool
319-
*/
320-
protected $mapped;
321-
322-
/**
323-
* Force the association property.
324-
*/
325-
protected $isAssociation;
326-
327-
/**
328-
* The source of data, if different from title and no dql specified.
329-
*/
330-
protected $dataSource;
331-
332299
//-------------------------------------------------
333300
// Options
334301
//-------------------------------------------------
@@ -359,10 +326,6 @@ public function configureOptions(OptionsResolver $resolver)
359326
'type_of_field' => null,
360327
'responsive_priority' => null,
361328
'sent_in_response' => true,
362-
'compute_total' => false,
363-
'mapped' => true,
364-
'is_association' => false,
365-
'data_source' => null,
366329
]);
367330

368331
$resolver->setAllowedTypes('cell_type', ['null', 'string']);
@@ -384,10 +347,6 @@ public function configureOptions(OptionsResolver $resolver)
384347
$resolver->setAllowedTypes('type_of_field', ['null', 'string']);
385348
$resolver->setAllowedTypes('responsive_priority', ['null', 'int']);
386349
$resolver->setAllowedTypes('sent_in_response', ['bool']);
387-
$resolver->setAllowedTypes('compute_total', ['bool']);
388-
$resolver->setAllowedTypes('mapped', ['bool']);
389-
$resolver->setAllowedTypes('is_association', ['bool']);
390-
$resolver->setAllowedTypes('data_source', ['string', 'null']);
391350

392351
$resolver->setAllowedValues('cell_type', [null, 'th', 'td']);
393352
$resolver->setAllowedValues('join_type', [null, 'join', 'leftJoin', 'innerJoin']);
@@ -433,10 +392,6 @@ public function isAssociation()
433392
*/
434393
public function isToManyAssociation()
435394
{
436-
if ($this->isAssociation) {
437-
return true;
438-
}
439-
440395
if (true === $this->isAssociation() && null !== $this->typeOfAssociation) {
441396
if (\in_array(ClassMetadataInfo::ONE_TO_MANY, $this->typeOfAssociation, true) || \in_array(ClassMetadataInfo::MANY_TO_MANY, $this->typeOfAssociation, true)) {
442397
return true;
@@ -475,9 +430,9 @@ public function addDataToOutputArray(array &$row)
475430
/**
476431
* {@inheritdoc}
477432
*/
478-
public function renderCellContent(array &$row, array &$resultRow)
433+
public function renderCellContent(array &$row)
479434
{
480-
$this->isToManyAssociation() ? $this->renderToMany($row, $resultRow) : $this->renderSingleField($row, $resultRow);
435+
$this->isToManyAssociation() ? $this->renderToMany($row) : $this->renderSingleField($row);
481436
}
482437

483438
/**
@@ -1021,6 +976,8 @@ public function setTypeOfAssociation($typeOfAssociation)
1021976
}
1022977

1023978
/**
979+
* Add a typeOfAssociation.
980+
*
1024981
* @param int $typeOfAssociation
1025982
*
1026983
* @return $this
@@ -1071,122 +1028,4 @@ public function setSentInResponse($sentInResponse)
10711028

10721029
return $this;
10731030
}
1074-
1075-
/**
1076-
* Get computeTotal.
1077-
*
1078-
* @return bool
1079-
*/
1080-
public function getComputeTotal()
1081-
{
1082-
return $this->computeTotal;
1083-
}
1084-
1085-
/**
1086-
* Set sentIntResponse.
1087-
*
1088-
* @param bool $computeTotal
1089-
*
1090-
* @return $this
1091-
*/
1092-
public function setComputeTotal($computeTotal)
1093-
{
1094-
$this->computeTotal = $computeTotal;
1095-
1096-
return $this;
1097-
}
1098-
1099-
/**
1100-
* Get total.
1101-
*/
1102-
public function getTotal()
1103-
{
1104-
return $this->total;
1105-
}
1106-
1107-
/**
1108-
* Set total.
1109-
*
1110-
* @param $total
1111-
*
1112-
* @return $this
1113-
*/
1114-
public function setTotal($total)
1115-
{
1116-
$this->total = $total;
1117-
1118-
return $this;
1119-
}
1120-
1121-
/**
1122-
* Get mapped.
1123-
*
1124-
* @return bool
1125-
*/
1126-
public function getMapped()
1127-
{
1128-
return $this->mapped;
1129-
}
1130-
1131-
/**
1132-
* Set mapped.
1133-
*
1134-
* @param bool $mapped
1135-
*
1136-
* @return $this
1137-
*/
1138-
public function setMapped($mapped)
1139-
{
1140-
$this->mapped = $mapped;
1141-
1142-
return $this;
1143-
}
1144-
1145-
/**
1146-
* Get isAssociation.
1147-
*
1148-
* @return bool
1149-
*/
1150-
public function getIsAssociation()
1151-
{
1152-
return $this->isAssociation;
1153-
}
1154-
1155-
/**
1156-
* Set isAssociation.
1157-
*
1158-
* @param bool $isAssociation
1159-
*
1160-
* @return $this
1161-
*/
1162-
public function setIsAssociation($isAssociation)
1163-
{
1164-
$this->isAssociation = $isAssociation;
1165-
1166-
return $this;
1167-
}
1168-
1169-
/**
1170-
* Get data source.
1171-
*
1172-
* @return string|null
1173-
*/
1174-
public function getDataSource()
1175-
{
1176-
return $this->isAssociation;
1177-
}
1178-
1179-
/**
1180-
* Set data source.
1181-
*
1182-
* @param string|null $dataSource
1183-
*
1184-
* @return $this
1185-
*/
1186-
public function setDataSource($dataSource)
1187-
{
1188-
$this->dataSource = $dataSource;
1189-
1190-
return $this;
1191-
}
11921031
}

Diff for: Datatable/Column/ActionColumn.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function addDataToOutputArray(array &$row)
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function renderSingleField(array &$row, array &$resultRow)
75+
public function renderSingleField(array &$row)
7676
{
7777
$parameters = [];
7878
$attributes = [];
@@ -132,7 +132,7 @@ public function renderSingleField(array &$row, array &$resultRow)
132132
}
133133
}
134134

135-
$resultRow[$this->getIndex()] = $this->twig->render(
135+
$row[$this->getIndex()] = $this->twig->render(
136136
$this->getCellContentTemplate(),
137137
[
138138
'actions' => $this->actions,
@@ -149,7 +149,7 @@ public function renderSingleField(array &$row, array &$resultRow)
149149
/**
150150
* {@inheritdoc}
151151
*/
152-
public function renderToMany(array &$row, array &$resultRow)
152+
public function renderToMany(array &$row)
153153
{
154154
throw new Exception('ActionColumn::renderToMany(): This function should never be called.');
155155
}

Diff for: Datatable/Column/ArrayColumn.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class ArrayColumn extends Column
1616
/**
1717
* {@inheritdoc}
1818
*/
19-
public function renderSingleField(array &$row, array &$resultRow)
19+
public function renderSingleField(array &$row)
2020
{
2121
$row[$this->data] = $this->arrayToString($row[$this->data] ?? []);
2222

23-
return parent::renderSingleField($row, $resultRow);
23+
return parent::renderSingleField($row);
2424
}
2525

2626
/**

Diff for: Datatable/Column/AttributeColumn.php

+7-13
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ class AttributeColumn extends AbstractColumn
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function renderSingleField(array &$row, array &$resultRow)
40+
public function renderSingleField(array &$row)
4141
{
42+
$renderAttributes = [];
43+
4244
$renderAttributes = \call_user_func($this->attributes, $row);
4345

4446
$path = Helper::getDataPropertyPath($this->data);
@@ -51,13 +53,13 @@ public function renderSingleField(array &$row, array &$resultRow)
5153
]
5254
);
5355

54-
$this->accessor->setValue($resultRow, $path, $content);
56+
$this->accessor->setValue($row, $path, $content);
5557
}
5658

5759
/**
5860
* {@inheritdoc}
5961
*/
60-
public function renderToMany(array &$row, array &$resultRow)
62+
public function renderToMany(array &$row)
6163
{
6264
$value = null;
6365
$path = Helper::getDataPropertyPath($this->data, $value);
@@ -81,7 +83,7 @@ public function renderToMany(array &$row, array &$resultRow)
8183
$currentObjectPath
8284
);
8385

84-
$this->accessor->setValue($resultRow, $currentPath, $content);
86+
$this->accessor->setValue($row, $currentPath, $content);
8587
}
8688
}
8789
// no placeholder - leave this blank
@@ -120,8 +122,6 @@ public function getColumnType()
120122
//-------------------------------------------------
121123

122124
/**
123-
* Config options.
124-
*
125125
* @return $this
126126
*/
127127
public function configureOptions(OptionsResolver $resolver)
@@ -140,8 +140,6 @@ public function configureOptions(OptionsResolver $resolver)
140140
}
141141

142142
/**
143-
* Get attributes.
144-
*
145143
* @return Attributes[]
146144
*/
147145
public function getAttributes()
@@ -150,8 +148,6 @@ public function getAttributes()
150148
}
151149

152150
/**
153-
* Set attributes.
154-
*
155151
* @param Closure $attributes
156152
*
157153
* @throws Exception
@@ -172,11 +168,9 @@ public function setAttributes($attributes)
172168
/**
173169
* Render template.
174170
*
175-
* @param string|null $data
176-
*
177171
* @return mixed|string
178172
*/
179-
private function renderTemplate($data)
173+
private function renderTemplate(?string $data)
180174
{
181175
return $this->twig->render(
182176
$this->getCellContentTemplate(),

Diff for: Datatable/Column/BooleanColumn.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class BooleanColumn extends AbstractColumn
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function renderSingleField(array &$row, array &$resultRow)
75+
public function renderSingleField(array &$row)
7676
{
7777
$path = Helper::getDataPropertyPath($this->data);
7878

@@ -83,7 +83,7 @@ public function renderSingleField(array &$row, array &$resultRow)
8383
$content = $this->renderTemplate($this->accessor->getValue($row, $path));
8484
}
8585

86-
$this->accessor->setValue($resultRow, $path, $content);
86+
$this->accessor->setValue($row, $path, $content);
8787
}
8888

8989
return $this;
@@ -92,7 +92,7 @@ public function renderSingleField(array &$row, array &$resultRow)
9292
/**
9393
* {@inheritdoc}
9494
*/
95-
public function renderToMany(array &$row, array &$resultRow)
95+
public function renderToMany(array &$row)
9696
{
9797
$value = null;
9898
$path = Helper::getDataPropertyPath($this->data, $value);
@@ -115,7 +115,7 @@ public function renderToMany(array &$row, array &$resultRow)
115115
$content = $this->renderTemplate($this->accessor->getValue($row, $currentPath));
116116
}
117117

118-
$this->accessor->setValue($resultRow, $currentPath, $content);
118+
$this->accessor->setValue($row, $currentPath, $content);
119119
}
120120
}
121121
// no placeholder - leave this blank

0 commit comments

Comments
 (0)