mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
after/before Create/Update in Record service
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user