entity set as being saved
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user