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

Commit

Permalink
Revert "Add attributes mapped, is_association and data_source (#914)"
Browse files Browse the repository at this point in the history
This reverts commit 593c3a2.
  • Loading branch information
Seb33300 authored Mar 23, 2020
1 parent 661438c commit ca200d3
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 267 deletions.
169 changes: 4 additions & 165 deletions Datatable/Column/AbstractColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,39 +296,6 @@ abstract class AbstractColumn implements ColumnInterface
* @var bool
*/
protected $sentInResponse;

/**
* If this column displays the total of its cells in its head
* Default: false.
*
* @var bool
*/
protected $computeTotal;

/**
* Contains the eventually computed total of the column.
*
* @var mixed
*/
protected $total;

/**
* If the column represents a real column in the database.
*
* @var bool
*/
protected $mapped;

/**
* Force the association property.
*/
protected $isAssociation;

/**
* The source of data, if different from title and no dql specified.
*/
protected $dataSource;

//-------------------------------------------------
// Options
//-------------------------------------------------
Expand Down Expand Up @@ -359,10 +326,6 @@ public function configureOptions(OptionsResolver $resolver)
'type_of_field' => null,
'responsive_priority' => null,
'sent_in_response' => true,
'compute_total' => false,
'mapped' => true,
'is_association' => false,
'data_source' => null,
]);

$resolver->setAllowedTypes('cell_type', ['null', 'string']);
Expand All @@ -384,10 +347,6 @@ public function configureOptions(OptionsResolver $resolver)
$resolver->setAllowedTypes('type_of_field', ['null', 'string']);
$resolver->setAllowedTypes('responsive_priority', ['null', 'int']);
$resolver->setAllowedTypes('sent_in_response', ['bool']);
$resolver->setAllowedTypes('compute_total', ['bool']);
$resolver->setAllowedTypes('mapped', ['bool']);
$resolver->setAllowedTypes('is_association', ['bool']);
$resolver->setAllowedTypes('data_source', ['string', 'null']);

$resolver->setAllowedValues('cell_type', [null, 'th', 'td']);
$resolver->setAllowedValues('join_type', [null, 'join', 'leftJoin', 'innerJoin']);
Expand Down Expand Up @@ -433,10 +392,6 @@ public function isAssociation()
*/
public function isToManyAssociation()
{
if ($this->isAssociation) {
return true;
}

if (true === $this->isAssociation() && null !== $this->typeOfAssociation) {
if (\in_array(ClassMetadataInfo::ONE_TO_MANY, $this->typeOfAssociation, true) || \in_array(ClassMetadataInfo::MANY_TO_MANY, $this->typeOfAssociation, true)) {
return true;
Expand Down Expand Up @@ -475,9 +430,9 @@ public function addDataToOutputArray(array &$row)
/**
* {@inheritdoc}
*/
public function renderCellContent(array &$row, array &$resultRow)
public function renderCellContent(array &$row)
{
$this->isToManyAssociation() ? $this->renderToMany($row, $resultRow) : $this->renderSingleField($row, $resultRow);
$this->isToManyAssociation() ? $this->renderToMany($row) : $this->renderSingleField($row);
}

/**
Expand Down Expand Up @@ -1021,6 +976,8 @@ public function setTypeOfAssociation($typeOfAssociation)
}

/**
* Add a typeOfAssociation.
*
* @param int $typeOfAssociation
*
* @return $this
Expand Down Expand Up @@ -1071,122 +1028,4 @@ public function setSentInResponse($sentInResponse)

return $this;
}

/**
* Get computeTotal.
*
* @return bool
*/
public function getComputeTotal()
{
return $this->computeTotal;
}

/**
* Set sentIntResponse.
*
* @param bool $computeTotal
*
* @return $this
*/
public function setComputeTotal($computeTotal)
{
$this->computeTotal = $computeTotal;

return $this;
}

/**
* Get total.
*/
public function getTotal()
{
return $this->total;
}

/**
* Set total.
*
* @param $total
*
* @return $this
*/
public function setTotal($total)
{
$this->total = $total;

return $this;
}

/**
* Get mapped.
*
* @return bool
*/
public function getMapped()
{
return $this->mapped;
}

/**
* Set mapped.
*
* @param bool $mapped
*
* @return $this
*/
public function setMapped($mapped)
{
$this->mapped = $mapped;

return $this;
}

/**
* Get isAssociation.
*
* @return bool
*/
public function getIsAssociation()
{
return $this->isAssociation;
}

/**
* Set isAssociation.
*
* @param bool $isAssociation
*
* @return $this
*/
public function setIsAssociation($isAssociation)
{
$this->isAssociation = $isAssociation;

return $this;
}

/**
* Get data source.
*
* @return string|null
*/
public function getDataSource()
{
return $this->isAssociation;
}

/**
* Set data source.
*
* @param string|null $dataSource
*
* @return $this
*/
public function setDataSource($dataSource)
{
$this->dataSource = $dataSource;

return $this;
}
}
6 changes: 3 additions & 3 deletions Datatable/Column/ActionColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function addDataToOutputArray(array &$row)
/**
* {@inheritdoc}
*/
public function renderSingleField(array &$row, array &$resultRow)
public function renderSingleField(array &$row)
{
$parameters = [];
$attributes = [];
Expand Down Expand Up @@ -132,7 +132,7 @@ public function renderSingleField(array &$row, array &$resultRow)
}
}

$resultRow[$this->getIndex()] = $this->twig->render(
$row[$this->getIndex()] = $this->twig->render(
$this->getCellContentTemplate(),
[
'actions' => $this->actions,
Expand All @@ -149,7 +149,7 @@ public function renderSingleField(array &$row, array &$resultRow)
/**
* {@inheritdoc}
*/
public function renderToMany(array &$row, array &$resultRow)
public function renderToMany(array &$row)
{
throw new Exception('ActionColumn::renderToMany(): This function should never be called.');
}
Expand Down
4 changes: 2 additions & 2 deletions Datatable/Column/ArrayColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class ArrayColumn extends Column
/**
* {@inheritdoc}
*/
public function renderSingleField(array &$row, array &$resultRow)
public function renderSingleField(array &$row)
{
$row[$this->data] = $this->arrayToString($row[$this->data] ?? []);

return parent::renderSingleField($row, $resultRow);
return parent::renderSingleField($row);
}

/**
Expand Down
20 changes: 7 additions & 13 deletions Datatable/Column/AttributeColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class AttributeColumn extends AbstractColumn
/**
* {@inheritdoc}
*/
public function renderSingleField(array &$row, array &$resultRow)
public function renderSingleField(array &$row)
{
$renderAttributes = [];

$renderAttributes = \call_user_func($this->attributes, $row);

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

$this->accessor->setValue($resultRow, $path, $content);
$this->accessor->setValue($row, $path, $content);
}

/**
* {@inheritdoc}
*/
public function renderToMany(array &$row, array &$resultRow)
public function renderToMany(array &$row)
{
$value = null;
$path = Helper::getDataPropertyPath($this->data, $value);
Expand All @@ -81,7 +83,7 @@ public function renderToMany(array &$row, array &$resultRow)
$currentObjectPath
);

$this->accessor->setValue($resultRow, $currentPath, $content);
$this->accessor->setValue($row, $currentPath, $content);
}
}
// no placeholder - leave this blank
Expand Down Expand Up @@ -120,8 +122,6 @@ public function getColumnType()
//-------------------------------------------------

/**
* Config options.
*
* @return $this
*/
public function configureOptions(OptionsResolver $resolver)
Expand All @@ -140,8 +140,6 @@ public function configureOptions(OptionsResolver $resolver)
}

/**
* Get attributes.
*
* @return Attributes[]
*/
public function getAttributes()
Expand All @@ -150,8 +148,6 @@ public function getAttributes()
}

/**
* Set attributes.
*
* @param Closure $attributes
*
* @throws Exception
Expand All @@ -172,11 +168,9 @@ public function setAttributes($attributes)
/**
* Render template.
*
* @param string|null $data
*
* @return mixed|string
*/
private function renderTemplate($data)
private function renderTemplate(?string $data)
{
return $this->twig->render(
$this->getCellContentTemplate(),
Expand Down
8 changes: 4 additions & 4 deletions Datatable/Column/BooleanColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BooleanColumn extends AbstractColumn
/**
* {@inheritdoc}
*/
public function renderSingleField(array &$row, array &$resultRow)
public function renderSingleField(array &$row)
{
$path = Helper::getDataPropertyPath($this->data);

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

$this->accessor->setValue($resultRow, $path, $content);
$this->accessor->setValue($row, $path, $content);
}

return $this;
Expand All @@ -92,7 +92,7 @@ public function renderSingleField(array &$row, array &$resultRow)
/**
* {@inheritdoc}
*/
public function renderToMany(array &$row, array &$resultRow)
public function renderToMany(array &$row)
{
$value = null;
$path = Helper::getDataPropertyPath($this->data, $value);
Expand All @@ -115,7 +115,7 @@ public function renderToMany(array &$row, array &$resultRow)
$content = $this->renderTemplate($this->accessor->getValue($row, $currentPath));
}

$this->accessor->setValue($resultRow, $currentPath, $content);
$this->accessor->setValue($row, $currentPath, $content);
}
}
// no placeholder - leave this blank
Expand Down
Loading

2 comments on commit ca200d3

@K0rell
Copy link

@K0rell K0rell commented on ca200d3 Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Hi, i have some bug after this commit

image

image

@Seb33300
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed on master already

Please sign in to comment.