| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 8 | class CreateUpdateAwareListener |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var User |
||
| 12 | */ |
||
| 13 | private $user; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * CreateUpdateAwareListener constructor. |
||
| 17 | * @param TokenStorage $tokenStorage |
||
| 18 | */ |
||
| 19 | public function __construct(TokenStorage $tokenStorage) |
||
| 22 | } |
||
| 23 | |||
| 24 | public function prePersist($entity) |
||
| 25 | { |
||
| 26 | if ($entity->getCreatedBy() === null) { |
||
| 27 | $entity->setCreatedAt(new \DateTime()); |
||
| 28 | $entity->setCreatedBy($this->user); |
||
| 29 | } |
||
| 30 | if ($entity->getUpdatedBy() === null) { |
||
| 31 | $entity->setUpdatedAt(new \DateTime()); |
||
| 32 | $entity->setUpdatedBy($this->user); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | public function preUpdate($entity) |
||
| 40 | } |
||
| 41 | } |
||
| 42 |