Skip to content

Commit 6264492

Browse files
committed
Make deleted value configurable for SoftDeleteableFilter.php
1 parent 59ce39e commit 6264492

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/Mapping/Annotation/SoftDeleteable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ final class SoftDeleteable implements GedmoAnnotation
3535

3636
public bool $hardDelete = true;
3737

38-
public ?string $deletedValue = null;
38+
public ?string $nonDeletedColumnValue = null;
3939

4040
/**
4141
* @param array<string, mixed> $data
4242
*/
43-
public function __construct(array $data = [], string $fieldName = 'deletedAt', bool $timeAware = false, bool $hardDelete = true, ?string $deletedValue = null)
43+
public function __construct(array $data = [], string $fieldName = 'deletedAt', bool $timeAware = false, bool $hardDelete = true, ?string $nonDeletedColumnValue = null)
4444
{
4545
if ([] !== $data) {
4646
Deprecation::trigger(
@@ -55,14 +55,14 @@ public function __construct(array $data = [], string $fieldName = 'deletedAt', b
5555
$this->fieldName = $this->getAttributeValue($data, 'fieldName', $args, 1, $fieldName);
5656
$this->timeAware = $this->getAttributeValue($data, 'timeAware', $args, 2, $timeAware);
5757
$this->hardDelete = $this->getAttributeValue($data, 'hardDelete', $args, 3, $hardDelete);
58-
$this->deletedValue = $this->getAttributeValue($data, 'deletedValue', $args, 4, $deletedValue);
58+
$this->nonDeletedColumnValue = $this->getAttributeValue($data, 'nonDeletedColumnValue', $args, 4, $nonDeletedColumnValue);
5959

6060
return;
6161
}
6262

6363
$this->fieldName = $fieldName;
6464
$this->timeAware = $timeAware;
6565
$this->hardDelete = $hardDelete;
66-
$this->deletedValue = $deletedValue;
66+
$this->nonDeletedColumnValue = $nonDeletedColumnValue;
6767
}
6868
}

src/SoftDeleteable/Filter/SoftDeleteableFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli
7070

7171
$column = $quoteStrategy->getColumnName($config['fieldName'], $targetEntity, $platform);
7272

73-
$addCondSql = $targetTableAlias.'.'.$column.' '.(isset($config['deletedValue']) ? '= '.$config['deletedValue'] : 'IS NULL');
73+
$addCondSql = $targetTableAlias.'.'.$column.' '.(isset($config['nonDeletedColumnValue']) ? '= '.$config['nonDeletedColumnValue'] : 'IS NULL');
7474
if (isset($config['timeAware']) && $config['timeAware']) {
7575
$addCondSql = "({$addCondSql} OR {$targetTableAlias}.{$column} > {$platform->getCurrentTimestampSQL()})";
7676
}

src/SoftDeleteable/Mapping/Driver/Attribute.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public function readExtendedMetadata($meta, array &$config)
6363
$config['hardDelete'] = $annot->hardDelete;
6464
}
6565

66-
if (isset($annot->deletedValue)) {
67-
if (!is_string($annot->deletedValue)) {
68-
throw new InvalidMappingException('deletedValue must be string. '.gettype($annot->deletedValue).' provided.');
66+
if (isset($annot->nonDeletedColumnValue)) {
67+
if (!is_string($annot->nonDeletedColumnValue)) {
68+
throw new InvalidMappingException('nonDeletedColumnValue must be string. '.gettype($annot->nonDeletedColumnValue).' provided.');
6969
}
7070

71-
$config['deletedValue'] = $annot->deletedValue;
71+
$config['nonDeletedColumnValue'] = $annot->nonDeletedColumnValue;
7272
}
7373
}
7474

src/SoftDeleteable/Mapping/Driver/Xml.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public function readExtendedMetadata($meta, array &$config)
5959
$config['hardDelete'] = $this->_getBooleanAttribute($xml->{'soft-deleteable'}, 'hard-delete');
6060
}
6161

62-
$config['deletedValue'] = null;
62+
$config['nonDeletedColumnValue'] = null;
6363
if ($this->_isAttributeSet($xml->{'soft-deleteable'}, 'deleted-value')) {
64-
$config['deletedValue'] = $this->_getAttribute($xml->{'soft-deleteable'}, 'deleted-value');
64+
$config['nonDeletedColumnValue'] = $this->_getAttribute($xml->{'soft-deleteable'}, 'non-deleted-column-value');
6565
}
6666
}
6767
}

src/SoftDeleteable/Mapping/Driver/Yaml.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public function readExtendedMetadata($meta, array &$config)
7171
$config['hardDelete'] = $classMapping['soft_deleteable']['hard_delete'];
7272
}
7373

74-
$config['deletedValue'] = null;
74+
$config['nonDeletedColumnValue'] = null;
7575
if (isset($classMapping['soft_deleteable']['deleted_value'])) {
7676
if (!is_string($classMapping['soft_deleteable']['deleted_value'])) {
77-
throw new InvalidMappingException('deletedValue must be string. '.gettype($classMapping['soft_deleteable']['deleted_value']).' provided.');
77+
throw new InvalidMappingException('nonDeletedColumnValue must be string. '.gettype($classMapping['soft_deleteable']['deleted_value']).' provided.');
7878
}
79-
$config['deletedValue'] = $classMapping['soft_deleteable']['deleted_value'];
79+
$config['nonDeletedColumnValue'] = $classMapping['soft_deleteable']['non_deleted_column_value'];
8080
}
8181
}
8282
}

0 commit comments

Comments
 (0)