public function updateRole(Role $r) { if ($r === null) { throw new Exceptions\NullPointerException("Argument Role cannot be null"); } try { $dbRole = $this->roleDao->find($r->getId()); if ($dbRole !== null) { $dbRole->fromArray($r->toArray()); $dbRole->setParents($this->roleParentsCollSetup($r)); //$dbRole->setAdded(new \Nette\Utils\DateTime()); // this might cause hierarchy problems $this->entityManager->merge($dbRole); $this->entityManager->flush(); $this->invalidateEntityCache($dbRole); $this->onUpdate(clone $dbRole); } } catch (DuplicateEntryException $e) { throw new Exceptions\DuplicateEntryException($e->getMessage(), $e->getCode(), $e->getPrevious()); } catch (\Exception $e) { $this->logError($e); throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious()); } }