repository refactoring

This commit is contained in:
Yuri Kuznetsov
2020-06-25 10:43:35 +03:00
parent 6c5dd4a120
commit cf586dcd75
13 changed files with 895 additions and 739 deletions
+5 -5
View File
@@ -31,9 +31,9 @@ namespace Espo\Repositories;
use Espo\ORM\Entity;
use \Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Error;
class ArrayValue extends \Espo\Core\ORM\Repositories\RDB
class ArrayValue extends \Espo\Core\Repositories\Database
{
protected $hooksDisabled = true;
@@ -43,7 +43,7 @@ class ArrayValue extends \Espo\Core\ORM\Repositories\RDB
protected $processFieldsAfterRemoveDisabled = true;
public function storeEntityAttribute(Entity $entity, $attribute, $populateMode = false)
public function storeEntityAttribute(Entity $entity, string $attribute, bool $populateMode = false)
{
if (!$entity->getAttributeType($attribute) === Entity::JSON_ARRAY) {
throw new Error("ArrayValue: Can't store non array attribute.");
@@ -89,13 +89,13 @@ class ArrayValue extends \Espo\Core\ORM\Repositories\RDB
'entityType' => $entity->getEntityType(),
'entityId' => $entity->id,
'attribute' => $attribute,
'value' => $value
'value' => $value,
]);
$this->save($arrayValue);
}
}
public function deleteEntityAttribute(Entity $entity, $attribute)
public function deleteEntityAttribute(Entity $entity, string $attribute)
{
if (!$entity->id) {
throw new Error("ArrayValue: Can't delete {$attribute} w/o id given.");