Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
     }
 }
Exemplo n.º 3
0
 public function __construct(EntityManager $em, Logger $logger)
 {
     parent::__construct($em, Role::getClassName(), $logger);
     $this->roleDao = $em->getDao(Role::getClassName());
     $this->positionDao = $em->getDao(Position::getClassName());
 }
Exemplo n.º 4
0
 public function updatePosition(Position $p)
 {
     if ($p === null) {
         throw new Exceptions\NullPointerException("Argument Position cannot be null");
     }
     try {
         $this->entityManager->beginTransaction();
         $pDb = $this->positionDao->find($p->getId());
         if ($pDb !== null) {
             $pDb->fromArray($p->toArray());
             $this->posGroupTypeHandle($pDb);
             $this->posOwnerTypeHandle($pDb);
             $this->posRoleTypeHandle($pDb);
             $this->entityManager->merge($pDb);
             $this->entityManager->flush();
         }
         $this->entityManager->commit();
         $this->onUpdate($pDb);
         $this->invalidateEntityCache($pDb);
     } catch (DuplicateEntryException $e) {
         $this->entityManager->rollback();
         $this->logError($e);
         throw new Exceptions\DuplicateEntryException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
 }