public function finish(Entities\IProcess $process, $exitCode = 0) { $process->setFinished(new \DateTime()); $process->setExitCode($exitCode); $process->setRunning(FALSE); $this->dao->save($process); }
public function createSportType(SportType $type) { if ($type == null) { throw new Exceptions\NullPointerException("Argument SportType cannot be null"); } try { $this->sportTypeDao->save($type); $this->invalidateEntityCache($type); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } $this->onCreate(clone $type); }
public function createSeasonApplication(SeasonApplication $app) { if ($app == null) { throw new Exceptions\NullPointerException("Argument SeasonApplication cannot be null"); } $now = new DateTime(); $this->applicationSeasonTypeHandle($app); $this->applicationGroupTypeHandle($app); try { if (!$this->isApplicationTime($app)) { throw new Exceptions\InvalidStateException("Deadline expired"); } } catch (Exceptions\NoResultException $ex) { throw new Exceptions\NoResultException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } $this->applicationPaymentTypeHandle($app); $this->applicationOwnerTypeHandle($app); $this->applicationEditorTypeHandle($app); $app->setUpdated($now); $app->setEnrolledTime($now); try { $this->seasonApplicationDao->save($app); $this->invalidateEntityCache($app); } catch (DuplicateEntryException $ex) { $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), Exceptions\DuplicateEntryException::SEASON_APPLICATION); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } $this->onCreate(clone $app); }
public function createComment(Comment $c) { if ($c === null) { throw new Exceptions\NullPointerException("Argument comment was null"); } try { $c->setUpdated(new DateTime()); $c->setCreated(new DateTime()); $c->setAuthor($c->getEditor()); $this->commentDao->save($c); $this->invalidateEntityCache($c); $this->onCreate($c); } catch (\Exception $ex) { throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createArticle(Article $a) { if ($a === NULL) { throw new Exceptions\NullPointerException("Argument Article was null"); } try { $this->entityManager->beginTransaction(); $a->setAuthor($a->getEditor()); $a->setUpdated(new DateTime()); $a->setCreated(new DateTime()); $this->sportGroupsTypeHandle($a); $a->setAlias(Strings::webalize($a->getTitle())); $identifier = $this->imageService->storeNetteFile($a->getPicture()); $a->setPicture($identifier); $this->articleDao->save($a); $this->invalidateEntityCache(); $this->entityManager->commit(); } catch (DBALException $ex) { $this->entityManager->rollback(); $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } catch (\Exception $ex) { $this->entityManager->rollback(); $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } $this->onCreate($a); }
public function updatePayment(Payment $p) { if ($p === NULL) { throw new Exceptions\NullPointerException("Argument Payment was null."); } try { $this->entityManager->beginTransaction(); $paymentDb = $this->paymentDao->find($p->getId(), false); if ($paymentDb !== null) { $paymentDb->fromArray($p->toArray()); $this->paymentOwnerTypeHandle($paymentDb); $this->paymentSeasonTypeHandle($paymentDb); $this->paymentEditorTypeHandle($paymentDb); $this->paymentDao->save($paymentDb); $this->invalidateEntityCache($paymentDb); $this->onUpdate($paymentDb); } $this->entityManager->commit(); } catch (DuplicateEntryException $ex) { $this->entityManager->rollback(); $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } catch (\Exception $ex) { $this->entityManager->rollback(); $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createWallPost(WallPost $w) { if ($w == null) { throw new Exceptions\NullPointerException("Argument WallPost cannot be null"); } try { $w->setAuthor($w->getEditor()); $w->setUpdated(new DateTime()); $this->sportGroupsTypeHandle($w); $this->wallDao->save($w); $this->invalidateEntityCache(); $this->onCreate(clone $w); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createEntry(MotivationEntry $e) { try { $e->setUpdated(new DateTime()); $this->entryEditorTypeHandle($e); $this->entryOwnerTypeHandle($e); $this->entrySeasonTypeHandle($e); $this->entryDao->save($e); $this->invalidateEntityCache($e); $this->onCreate($e); } catch (DuplicateEntryException $ex) { $this->logWarning($ex->getMessage()); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createRule(AclRule $arule) { if ($arule === null) { throw new Exceptions\NullPointerException("Argument AclRule cannot be null"); } try { $this->roleTypeHandle($arule); $this->aclRuleDao->save($arule); $this->invalidateEntityCache($arule); } catch (DuplicateEntryException $e) { $this->logWarning($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()); } $this->onCreate($arule); }
public function createPartner(Partner $p) { try { $p->setUpdated(new DateTime()); $this->editorTypeHandle($p); $this->referrerTypeHandle($p); $identifier = $this->imageService->storeNetteFile($p->getPicture()); $p->setPicture($identifier); $this->partnerDao->save($p); $this->invalidateEntityCache($p); $this->onCreate($p); } catch (\Kdyby\Doctrine\DuplicateEntryException $ex) { $this->logWarning($ex->getMessage()); throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createRole(Role $r) { if ($r === null) { throw new Exceptions\NullPointerException("Argument Role cannot be null"); } try { $r->setParents($this->roleParentsCollSetup($r)); $r->setAdded(new DateTime()); $this->roleDao->save($r); $this->invalidateEntityCache(); $this->onCreate($r); } catch (DuplicateEntryException $e) { $this->logWarning($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()); } }
public function createSportGroup(SportGroup $g) { if ($g == null) { throw new Exceptions\NullPointerException("Argument SportGroup cannot be null"); } try { $this->groupParentHandle($g); $this->groupSportTypeHandle($g); $this->groupDao->save($g); $this->invalidateEntityCache($g); } catch (DuplicateEntryException $ex) { $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } $this->onCreate(clone $g); }
public function createPosition(Position $p) { if ($p === null) { throw new Exceptions\NullPointerException("Argument Position cannot be null"); } try { $this->posGroupTypeHandle($p); $this->posOwnerTypeHandle($p); $this->posRoleTypeHandle($p); $this->positionDao->save($p); $this->invalidateEntityCache($p); $this->onCreate($p); } catch (DuplicateEntryException $e) { $this->logWarning($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()); } }
/** * @param string $name * @param string $email * @param string $password * @param Role[]|string[] $roles */ public function create($name, $email, $password, $roles = []) { $user = new User(); $user->name = $name; $user->email = $email; $this->passwordStrategy->setPassword($user, $password); $roles = (array) $roles; foreach ($roles as $role) { if (is_string($role)) { if (!($role = $this->rolesRepository->findBy(['name' => $role]))) { throw new \RuntimeException("Unknown role '{$role}'."); } } elseif (!$role instanceof Role) { throw new \UnexpectedValueException("Role must be string or instance of Rixxi\\User\\Entities\\Role"); } $user->roles->add($role); } $this->repository->save($user); return $user; }
public function createSeason(Season $s) { if ($s === null) { throw new Exceptions\NullPointerException("Argument Season cannot be null", 0); } try { if ($s->getCurrent()) { $this->setAllSeasonsAsInactive(); } $this->seasonEditorTypeHandle($s); $s->setUpdated(new DateTime()); $this->seasonDao->save($s); $this->invalidateEntityCache($s); $this->onCreate($s); } catch (DuplicateEntryException $ex) { $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), Exceptions\DuplicateEntryException::SEASON_LABEL, $ex->getPrevious()); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
/** * @param Brabijan\SeoComponents\Entity\Route $route */ public function delete(Brabijan\SeoComponents\Entity\Route $route) { $target = $route->target; $isRouteOneWay = $route->oneWay; $this->routeDao->delete($route); if ($isRouteOneWay === FALSE) { $target = new Brabijan\SeoComponents\Router\Target($target->targetPresenter, $target->targetAction, $target->targetId); $currentRoute = $this->findCurrentRouteByTarget($target); if ($currentRoute) { $this->cleanTargetCache($target); $currentRoute->oneWay = FALSE; $this->routeDao->save($currentRoute); } } }
public function createStaticPage(StaticPage $sp) { try { $this->entityManager->beginTransaction(); $sp->setUpdated(new DateTime()); $this->sportGroupTypeHandle($sp); $this->handleAbbrConsistency($sp); $this->editorTypeHandle($sp); $this->pageDao->save($sp); $this->entityManager->commit(); $this->invalidateEntityCache($sp); } catch (\Exception $ex) { $this->entityManager->rollback(); $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } $this->onCreate(clone $sp); }
public function createEvent(Event $e) { if ($e === NULL) { throw new Exceptions\NullPointerException("Argument Event was null"); } try { $e->setEditor($e->getAuthor()); $e->setUpdated(new DateTime()); $e->setAlias(Strings::webalize($e->getTitle())); $this->sportGroupsTypeHandle($e); $this->eventDao->save($e); $this->invalidateEntityCache($e); $this->onCreate($e); } catch (DBALException $ex) { $this->logWarning($ex); throw new Exceptions\DuplicateEntryException("Event with this title already exist"); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createSeasonTax(SeasonTax $t) { if ($t === null) { throw new Exceptions\NullPointerException("Argument SeasonTax cannot be null", 0); } try { $this->taxSeasonTypeHandle($t); $this->taxSportGroupTypeHandle($t); $this->taxEditorTypeHandle($t); $t->setChanged(new DateTime()); $this->seasonTaxDao->save($t); $this->invalidateEntityCache($t); $this->onCreate($t); } catch (DuplicateEntryException $ex) { $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), Exceptions\DuplicateEntryException::SEASON_TAX, $ex->getPrevious()); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function createUser(User $user) { $now = new DateTime(); $rawPass = null; $userPass = $user->getPassword(); if (empty($userPass)) { $rawPass = Strings::random(self::RANDOM_PASS_LENGTH); } else { $rawPass = $user->getPassword(); } $this->entityManager->beginTransaction(); $user->setPassword($this->generateNewPassword($rawPass)); $user->setCreated($now); $user->setUpdated($now); $user->setWebProfile(new WebProfile()); $user->contact->setUpdated($now); $user->getWebProfile()->setUpdated($now); $user->getWebProfile()->setStatus(WebProfileStatus::BAD); try { $this->contactDao->save($user->getContact()); } catch (DuplicateEntryException $e) { $this->entityManager->rollback(); throw new Exceptions\DuplicateEntryException($e->getMessage(), Exceptions\DuplicateEntryException::EMAIL_EXISTS, $e->getPrevious()); } try { $this->userDao->save($user); $this->entityManager->commit(); } catch (DuplicateEntryException $e) { $this->entityManager->rollback(); throw new Exceptions\DuplicateEntryException($e->getMessage(), Exceptions\DuplicateEntryException::BIRTH_NUM_EXISTS, $e->getPrevious()); } catch (\Exception $e) { $this->entityManager->rollback(); $this->logError($e->getMessage()); throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious()); } $this->logInfo("User %user was successfully created", ["user" => $user]); $user->insertRawPassword($rawPass); $this->onCreate(clone $user); }
public function createForum(Forum $f) { try { $this->entityManager->beginTransaction(); $f->setUpdated(new DateTime()); $f->setAuthor($f->getEditor()); $this->sportGroupsTypeHandle($f); $f->setAlias(Strings::webalize($f->getTitle())); $this->forumDao->save($f); $this->entityManager->commit(); $this->invalidateEntityCache($f); $this->onCreate($f); } catch (DBALException $ex) { $this->entityManager->rollback(); $this->logWarning($ex); throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } catch (\Exception $ex) { $this->entityManager->rollback(); $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
/** * @param \Brabijan\SeoComponents\Entity\Meta $meta */ public function save(\Brabijan\SeoComponents\Entity\Meta $meta) { $this->metaDao->save($meta); }
/** * @param null $entity \Entity\Post * @param null $relations * @return array * * @Secure\Create(allow="admin") * @Secure\Update(allow="admin") */ public function save($entity = NULL, $relations = NULL) { $entity = $this->dao->save($entity, $relations); $this->onSave($entity->id); return $entity; }
/** * @return array */ public function save($entity = NULL, $relations = NULL) { return $this->dao->save($entity, $relations); }
public function save(User $user) { $this->userDao->save($user); }
/** * @param Entity\Settings $setting */ public function save(Entity\Settings $setting) { $this->settingsDao->save($setting); }
/** * @param \Brabijan\SeoComponents\Entity\Target $target */ public function save(\Brabijan\SeoComponents\Entity\Target $target) { $this->targetDao->save($target); }