Skip to content

Commit

Permalink
Merge branch 'hotfix/4.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
pfilsx committed Nov 15, 2019
2 parents f96952b + 18cf8a6 commit 73a5718
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
17 changes: 14 additions & 3 deletions src/Grid/Columns/DataColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DataColumn extends AbstractColumn
protected $attribute;
protected $format = 'raw';
protected $sort = true;
protected $emptyValue = '';

/**
* @param mixed $attribute
Expand Down Expand Up @@ -54,6 +55,16 @@ protected function setFormat(string $format): void
$this->format = strtolower($format);
}

public function getEmptyValue()
{
return $this->emptyValue;
}

protected function setEmptyValue($value): void
{
$this->emptyValue = $value;
}

protected function checkConfiguration()
{
if ((!is_string($this->attribute) || empty($this->attribute)) && $this->value === null) {
Expand Down Expand Up @@ -86,9 +97,9 @@ public function getFilterContent()
public function getCellContent($entity)
{
$result = (string)$this->getCellValue($entity);
return $this->format === 'html'
? $result
: htmlspecialchars($result);
return empty($result)
? $this->emptyValue
: ($this->format === 'html' ? $result : htmlspecialchars($result));
}

protected function getCellValue($entity)
Expand Down
3 changes: 2 additions & 1 deletion src/Grid/Columns/DateColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function getCellContent($entity)
} elseif (is_string($value) && !empty($this->dateFormat)) {
return date($this->dateFormat, strtotime($value));
}
return (string)$value;
$value = (string)$value;
return empty($value) ? $this->emptyValue : $value;
}

/**
Expand Down
20 changes: 2 additions & 18 deletions src/Grid/Columns/ImageColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ImageColumn extends DataColumn

protected $alt;

protected $noImageMessage = '-';
protected $emptyValue = '-';

public function getCellContent($entity)
{
Expand All @@ -33,7 +33,7 @@ public function getCellContent($entity)
}
return htmlspecialchars($value);
} else {
return $this->noImageMessage;
return $this->emptyValue;
}
}

Expand Down Expand Up @@ -87,20 +87,4 @@ protected function setAlt(callable $alt): void
{
$this->alt = $alt;
}

/**
* @return string
*/
public function getNoImageMessage(): string
{
return $this->noImageMessage;
}

/**
* @param string $noImageMessage
*/
protected function setNoImageMessage(string $noImageMessage): void
{
$this->noImageMessage = $noImageMessage;
}
}
2 changes: 1 addition & 1 deletion src/Grid/Columns/RelationColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getCellContent($entity)
? $result
: htmlspecialchars($result);
}
return is_string($obj) ? $obj : '';
return is_string($obj) ? (empty($obj) ? $this->emptyValue : $obj) : $this->emptyValue;
}

/**
Expand Down

0 comments on commit 73a5718

Please sign in to comment.