array value cleanup
This commit is contained in:
@@ -41,6 +41,8 @@ class ArrayValue extends \Espo\Core\ORM\Repositories\RDB
|
||||
|
||||
protected $processFieldsBeforeSaveDisabled = true;
|
||||
|
||||
protected $processFieldsAfterRemoveDisabled = true;
|
||||
|
||||
public function storeEntityAttribute(Entity $entity, $attribute, $populateMode = false)
|
||||
{
|
||||
if (!$entity->getAttributeType($attribute) === Entity::JSON_ARRAY) {
|
||||
@@ -92,4 +94,20 @@ class ArrayValue extends \Espo\Core\ORM\Repositories\RDB
|
||||
$this->save($arrayValue);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteEntityAttribute(Entity $entity, $attribute)
|
||||
{
|
||||
if (!$entity->id) {
|
||||
throw new Error("ArrayValue: Can't delete {$attribute} w/o id given.");
|
||||
}
|
||||
$list = $this->select(['id'])->where([
|
||||
'entityType' => $entity->getEntityType(),
|
||||
'entityId' => $entity->id,
|
||||
'attribute' => $attribute
|
||||
])->find();
|
||||
|
||||
foreach ($list as $arrayValue) {
|
||||
$this->deleteFromDb($arrayValue->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user