This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Core/ORM/Repository.php
T
Yuri Kuznetsov 58f2288b03 dev
2013-12-19 14:46:33 +02:00

36 lines
756 B
PHP

<?php
namespace Espo\Core\ORM;
use \Espo\ORM\Entity;
class Repository extends \Espo\ORM\Repository
{
public function save(Entity $entity)
{
if ($entity->isNew()) {
if ($entity->hasField('createdAt')) {
$entity->set('createdAt', date());
}
if ($entity->hasField('createdById')) {
$entity->set('createdById', $this->entityManager->user->id);
}
$entity->clear('modifiedById');
$entity->clear('modifiedAt');
} else {
if ($entity->hasField('modifiedAt')) {
$entity->set('modifiedAt', date());
}
if ($entity->hasField('modifiedById')) {
$entity->set('modifiedById', $this->entityManager->user->id);
}
$entity->clear('createdById');
$entity->clear('createdAt');
}
parent::save($entity);
}
}