/** * onCreate event handler * @param SeasonApplication $app */ public function onCreate(SeasonApplication $app) { $id = $this->defaultRoleName; try { if (!is_string($id)) { $role = $this->roleService->getRole($id); } else { $role = $this->roleService->getRoleName($id); } } catch (Exceptions\DataErrorException $ex) { $this->logger->addError("Application listener - onCreate - role load failed with - " . $ex->getMessage()); return; } $pos = new Position(); $pos->setGroup($app->getSportGroup()); $pos->setRole($role); $pos->setOwner($app->getOwner()); $pos->setPublishContact(false); $pos->setComment($this->defaultComment); try { $this->positionService->createPosition($pos); if ($this->deleteOldPosition) { $this->positionService->deletePositionsWithRole($pos->getOwner(), $pos->getRole()); } } catch (Exceptions\DataErrorException $ex) { $this->logger->addError("Application listener - onCreate - savingData failed with - " . $ex->getMessage()); return; } }
public function positionsInit() { $pos = null; try { $user = $this->userService->getUserEmail($this->getDefaultUserEmail()); $role = $this->roleService->getRoleName("admin"); $group = $this->groupService->getSportGroupAbbr("root"); } catch (Exceptions\NoResultException $ex) { return null; } try { $pos = $this->positionService->getUniquePosition($user, $group, $role); } catch (Exceptions\NoResultException $ex) { $this->logger->addDebug($ex->getMessage()); } if ($pos === null) { $this->logger->addInfo("Security module initializer - Position - no position with user {$user}, role {$role} and group {$group} found. New one is gonna be created."); $pos = new Position(); $pos->setGroup($group); $pos->setOwner($user); $pos->setRole($role); $pos->setName("Webmaster"); $pos->setComment("System created"); $this->positionService->createPosition($pos); } }
private function posGroupTypeHandle(Position $p) { if ($p === null) { throw new Exceptions\NullPointerException("Argument Position was null"); } try { $group = null; $id = $this->getMixId($p->getGroup()); if ($id !== null) { $group = $this->sportGroupService->getSportGroup($id, false); } $p->setGroup($group); } catch (\Exception $e) { $this->logError($e); throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious()); } return $p; }