diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index dcb870db08..de58f5569a 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -297,6 +297,8 @@ class Record extends \Espo\Core\Services\Base $entity->set($data); + $this->beforeCreate($entity); + if (!$this->isValid($entity)) { throw new BadRequest(); } @@ -313,6 +315,7 @@ class Record extends \Espo\Core\Services\Base } if ($this->storeEntity($entity)) { + $this->afterCreate($entity); $this->prepareEntityForOutput($entity); return $entity; } @@ -348,11 +351,14 @@ class Record extends \Espo\Core\Services\Base $entity->set($data); + $this->beforeUpdate($entity); + if (!$this->isValid($entity)) { throw new BadRequest(); } if ($this->storeEntity($entity)) { + $this->afterUpdate($entity); $this->prepareEntityForOutput($entity); return $entity; } @@ -360,6 +366,22 @@ class Record extends \Espo\Core\Services\Base throw new Error(); } + protected function beforeCreate(Entity $entity) + { + } + + protected function afterCreate(Entity $entity) + { + } + + protected function beforeUpdate(Entity $entity) + { + } + + protected function afterUpdate(Entity $entity) + { + } + public function deleteEntity($id) { if (empty($id)) {