Esempio n. 1
0
 public function insert(Area $item)
 {
     $this->transaction->requestTransaction();
     try {
         $id = $item->insert($this->conn);
         $this->eventDispatcher->dispatch(CantigaEvents::AREA_CREATED, new AreaEvent($item));
         return $id;
     } catch (Exception $exception) {
         $this->transaction->requestRollback();
         throw $exception;
     }
 }
Esempio n. 2
0
 public function approve(Connection $conn, MembershipRoleResolver $resolver)
 {
     $this->status = $conn->fetchColumn('SELECT `status` FROM `' . CoreTables::AREA_REQUEST_TBL . '` WHERE `id` = :id', [':id' => $this->id]);
     if ($this->status == self::STATUS_VERIFICATION) {
         $this->lastUpdatedAt = time();
         $this->status = self::STATUS_APPROVED;
         $conn->update(CoreTables::AREA_REQUEST_TBL, ['lastUpdatedAt' => $this->lastUpdatedAt, 'status' => $this->status], ['id' => $this->getId()]);
         $area = new Area();
         $area->setName($this->name);
         $area->setProject($this->project);
         $area->setTerritory($this->territory);
         $area->setReporter($this->requestor);
         // oops, naming inconsistency
         $id = $area->insert($conn);
         $conn->update(CoreTables::AREA_REQUEST_TBL, ['areaId' => $id], ['id' => $this->getId()]);
         $area->joinMember($conn, $this->requestor, $resolver->getHighestRole('Area'), '');
         return $area;
     }
     return false;
 }