Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! chore: Cleanup methods to parse/transform…
Browse files Browse the repository at this point in the history
… values
  • Loading branch information
juliusknorr committed Jul 31, 2024
1 parent e619007 commit b69b694
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/Db/RowCellSelectionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, $this->table, RowCellSelection::class);
}

/**
* @inheritDoc
*/
public function filterValueToQueryParam(Column $column, $value) {
return $this->valueToJsonDbValue($column, $value);
}

public function applyDataToEntity(Column $column, RowCellSuper $cell, $data): void {
$cell->setValue($this->valueToJsonDbValue($column, $data));
}

public function formatEntity(Column $column, RowCellSuper $cell) {
return json_decode($cell->getValue());
}

private function valueToJsonDbValue(Column $column, $value): string {
if ($column->getSubtype() === 'check') {
return json_encode(ltrim($value, '"'));
Expand All @@ -28,15 +37,4 @@ private function valueToJsonDbValue(Column $column, $value): string {

return json_encode($value);
}

public function applyDataToEntity(Column $column, RowCellSuper $cell, $data): void {
$cell->setValue($this->valueToJsonDbValue($column, $data));
}

/**
* @inheritDoc
*/
public function formatEntity(Column $column, RowCellSuper $cell) {
return json_decode($cell->getValue());
}
}

0 comments on commit b69b694

Please sign in to comment.