Exemplo n.º 1
0
 public function deleteEndpoint(\EndpointLocation $endpoint, \User $user)
 {
     require_once __DIR__ . '/../DAOs/ServiceDAO.php';
     //Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     $service = $endpoint->getService();
     // check user has permission to edit endpoint's service
     $this->validateAddEditDeleteActions($user, $service);
     $this->em->getConnection()->beginTransaction();
     try {
         $serviceDAO = new \ServiceDAO();
         $serviceDAO->setEntityManager($this->em);
         $serviceDAO->removeEndpoint($endpoint);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * Queues an EndpointLocation for removal by unlinking its associations 
  * with Service and Downtime.
  * <p> 
  * No authorisation or validation occurs here.
  * Non-transactional - invokes remove() of the EntityManager 
  * but does not call flush(), commit() or rollback(). 
  * 
  * @param \EndpointLocation $endpoint
  */
 public function removeEndpoint(\EndpointLocation $endpoint)
 {
     $service = $endpoint->getService();
     // unset relation on both sides (SE<-->EL)
     $service->getEndpointLocations()->removeElement($endpoint);
     $endpoint->setServiceDoJoin(NULL);
     // unset relation on both sides (EL<-->DT)
     foreach ($endpoint->getDowntimes() as $dt) {
         $endpoint->getDowntimes()->removeElement($dt);
         $dt->getEndpointLocations()->removeElement($endpoint);
     }
     // Once relationships are removed delete the actual element
     $this->em->remove($endpoint);
 }