after/before Create/Update in Record service

This commit is contained in:
yuri
2015-02-03 12:43:56 +02:00
parent 230ed63e67
commit 0dc5a4e4f3

View File

@@ -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)) {