Ejemplo n.º 1
0
 public static function fetchByRoot(Connection $conn, $id, MembershipEntityInterface $root)
 {
     if ($root instanceof Area) {
         $data = $conn->fetchAssoc('SELECT * FROM `' . EdkTables::MESSAGE_TBL . '` WHERE `id` = :id AND `areaId` = :rootId', [':id' => $id, ':rootId' => $root->getId()]);
     } elseif ($root instanceof Group) {
         $data = $conn->fetchAssoc('SELECT m.* FROM `' . EdkTables::MESSAGE_TBL . '` m ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON a.`id` = m.`areaId` ' . 'WHERE m.`id` = :id AND a.`groupId` = :rootId', [':id' => $id, ':rootId' => $root->getId()]);
     } elseif ($root instanceof Project) {
         $data = $conn->fetchAssoc('SELECT m.* FROM `' . EdkTables::MESSAGE_TBL . '` m ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON a.`id` = m.`areaId` ' . 'WHERE m.`id` = :id AND a.`projectId` = :rootId', [':id' => $id, ':rootId' => $root->getId()]);
     }
     if (false === $data) {
         return false;
     }
     $item = self::fromArray($data);
     if ($root instanceof Area) {
         $item->area = $root;
     } elseif ($root instanceof Group) {
         $item->area = Area::fetchByGroup($conn, $data['areaId'], $root);
     } elseif ($root instanceof Project) {
         $item->area = Area::fetchByProject($conn, $data['areaId'], $root);
     }
     if (!empty($data['responderId'])) {
         $item->responder = User::fetchByCriteria($conn, QueryClause::clause('u.id = :id', ':id', $data['responderId']));
     }
     return $item;
 }
 /**
  * Fetches an area by its ID and the project.
  * 
  * @param int $id
  * @param Project $project
  */
 public function getItem($id, Project $project)
 {
     $item = Area::fetchByProject($this->conn, $id, $project);
     if (false === $item) {
         throw new ItemNotFoundException('AreaNotFound', $id);
     }
     return $item;
 }
Ejemplo n.º 3
0
 /**
  * @return Area
  */
 public function getArea($id)
 {
     $this->transaction->requestTransaction();
     try {
         $item = Area::fetchByProject($this->conn, $id, $this->project);
         if (false === $item || $item->getStatus()->getId() != $this->publishedStatusId || $item->getProject()->getArchived()) {
             $this->transaction->requestRollback();
             throw new ItemNotFoundException('The specified area has not been found.', $id);
         }
         return $item;
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
 public function getItem($id)
 {
     $this->transaction->requestTransaction();
     try {
         $item = Area::fetchByProject($this->conn, $id, $this->project);
         if (false === $item) {
             $this->transaction->requestRollback();
             throw new ItemNotFoundException('The specified item has not been found.', $id);
         }
         return $item;
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
Ejemplo n.º 5
0
 public static function fetchByRoot(Connection $conn, $id, MembershipEntityInterface $root)
 {
     if ($root instanceof Area) {
         $data = $conn->fetchAssoc('SELECT * FROM `' . EdkTables::ROUTE_TBL . '` WHERE `areaId` = :areaId AND `id` = :id', [':id' => $id, ':areaId' => $root->getId()]);
     } elseif ($root instanceof Group) {
         $data = $conn->fetchAssoc('SELECT r.* ' . 'FROM `' . EdkTables::ROUTE_TBL . '` r ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON a.`id` = r.`areaId` ' . 'WHERE a.`groupId` = :groupId AND r.`id` = :id', [':id' => $id, ':groupId' => $root->getId()]);
     } elseif ($root instanceof Project) {
         $data = $conn->fetchAssoc('SELECT r.* ' . 'FROM `' . EdkTables::ROUTE_TBL . '` r ' . 'INNER JOIN `' . CoreTables::AREA_TBL . '` a ON a.`id` = r.`areaId` ' . 'WHERE a.`projectId` = :projectId AND r.`id` = :id', [':id' => $id, ':projectId' => $root->getId()]);
     }
     if (false === $data) {
         return false;
     }
     $item = self::fromArray($data);
     if ($root instanceof Area) {
         $item->area = $root;
     } elseif ($root instanceof Group) {
         $item->area = Area::fetchByGroup($conn, $data['areaId'], $root);
     } elseif ($root instanceof Project) {
         $item->area = Area::fetchByProject($conn, $data['areaId'], $root);
     }
     $notes = $conn->fetchAll('SELECT * FROM `' . EdkTables::ROUTE_NOTE_TBL . '` WHERE `routeId` = :routeId', [':routeId' => $item->getId()]);
     foreach ($notes as $note) {
         $item->notes[$note['noteType']] = $note['content'];
     }
     return $item;
 }