entity set as being saved

This commit is contained in:
yuri
2018-08-30 14:30:17 +03:00
parent 083770f705
commit bb63751332
2 changed files with 21 additions and 1 deletions
+17 -1
View File
@@ -72,6 +72,8 @@ abstract class Entity implements IEntity
protected $isFetched = false;
protected $isBeingSaved = false;
public function __construct($defs = array(), EntityManager $entityManager = null)
{
if (empty($this->entityType)) {
@@ -486,6 +488,21 @@ abstract class Entity implements IEntity
$this->resetFetchedValues();
}
public function isBeingSaved()
{
return $this->isBeingSaved;
}
public function setAsBeingSaved()
{
$this->isBeingSaved = true;
}
public function setAsNotBeingSaved()
{
$this->isBeingSaved = false;
}
public function populateDefaults()
{
foreach ($this->fields as $field => $defs) {
@@ -500,4 +517,3 @@ abstract class Entity implements IEntity
return $this->entityManager;
}
}
@@ -141,6 +141,8 @@ class RDB extends \Espo\ORM\Repository
public function save(Entity $entity, array $options = array())
{
$entity->setAsBeingSaved();
if (empty($options['skipBeforeSave']) && empty($options['skipAll'])) {
$this->beforeSave($entity, $options);
}
@@ -164,6 +166,8 @@ class RDB extends \Espo\ORM\Repository
}
}
}
$entity->setAsNotBeingSaved();
return $result;
}