| @@ 37-47 (lines=11) @@ | ||
| 34 | * |
|
| 35 | * @throws ObjectClassNotAllowedException |
|
| 36 | */ |
|
| 37 | public function insert(Entity $object) |
|
| 38 | { |
|
| 39 | if (!$this->getSupport($object)) { |
|
| 40 | throw new ObjectClassNotAllowedException(); |
|
| 41 | ||
| 42 | } |
|
| 43 | $object->setCreatedAt(new DateTime()); |
|
| 44 | $this->entityManager->persist($object); |
|
| 45 | $this->entityManager->flush(); |
|
| 46 | ||
| 47 | return $object; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| @@ 57-66 (lines=10) @@ | ||
| 54 | * |
|
| 55 | * @throws ObjectClassNotAllowedException |
|
| 56 | */ |
|
| 57 | public function update(Entity $object) |
|
| 58 | { |
|
| 59 | if (!$this->getSupport($object)) { |
|
| 60 | throw new ObjectClassNotAllowedException(); |
|
| 61 | } |
|
| 62 | $object->setUpdatedAt(new DateTime()); |
|
| 63 | $this->entityManager->flush(); |
|
| 64 | ||
| 65 | return $object; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Finds an entity by its primary key / identifier. |
|