Exemplo n.º 1
0
 public static function fetchByRoute(Connection $conn, EdkRoute $route)
 {
     $data = $conn->fetchAssoc('SELECT * FROM `' . EdkTables::REGISTRATION_SETTINGS_TBL . '` WHERE `routeId` = :id', [':id' => $route->getId()]);
     if (false === $data) {
         $item = new EdkRegistrationSettings();
         $item->isNew = true;
     } else {
         $item = self::fromArray($data);
     }
     $item->route = $route;
     return $item;
 }
 /**
  * @return EdkRegistrationSettings
  */
 public function getItem($id)
 {
     $this->transaction->requestTransaction();
     try {
         $route = EdkRoute::fetchByRoot($this->conn, $id, $this->root);
         if (empty($route)) {
             throw new ItemNotFoundException('The specified route has not been found.');
         }
         return EdkRegistrationSettings::fetchByRoute($this->conn, $route);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }
Exemplo n.º 3
0
 /**
  * Fetches the participant by his/her ID and area.
  * 
  * @param Connection $conn
  * @param int $id
  * @param Area $area
  * @param boolean $forUpdate Whether to lock the registration settings for writing
  * @return EdkParticipant
  */
 public static function fetchByArea(Connection $conn, $id, Area $area)
 {
     $data = $conn->fetchAssoc('SELECT * FROM `' . EdkTables::PARTICIPANT_TBL . '` WHERE `id` = :id AND `areaId` = :areaId', [':id' => $id, ':areaId' => $area->getId()]);
     if (false === $data) {
         return false;
     }
     $route = EdkRoute::fetchByRoot($conn, $data['routeId'], $area);
     if (empty($route)) {
         return false;
     }
     $registrationSettings = EdkRegistrationSettings::fetchByRoute($conn, $route);
     if (empty($registrationSettings)) {
         return false;
     }
     $item = EdkParticipant::fromArray($data);
     $item->setRegistrationSettings($registrationSettings);
     return $item;
 }
Exemplo n.º 4
0
 private function getActivationFunc(EdkRoute $route)
 {
     $conn = $this->conn;
     return function () use($conn, $route) {
         $count = $conn->fetchColumn('SELECT COUNT(`id`) FROM `' . EdkTables::ROUTE_TBL . '` WHERE `approved` = 1 AND `routeType` = ' . EdkRoute::TYPE_FULL . ' AND `areaId` = :areaId', [':areaId' => $route->getArea()->getId()]);
         return NewMilestoneStatus::create($count > 0);
     };
 }