예제 #1
0
 /**
  * Logout method
  */
 public function logout()
 {
     try {
         $this->curl->exec($this->routes->getLogoutUrl());
         $this->cookieStorage->deleteCurlCookieFile();
     } catch (\Exception $e) {
         throw new AlmAuthenticationException('Authentication error : ' . $e->getMessage());
     }
     return $this;
 }
예제 #2
0
 /**
  * @param AlmEntity $entity
  * @return AlmEntity
  * @throws AlmEntityManagerException
  * @throws Exception\AlmCurlException
  * @throws Exception\AlmException
  */
 public function save(AlmEntity $entity)
 {
     $headers = array('Accept: application/xml', 'Content-Type: application/xml');
     if ($entity->isNew()) {
         $entityXml = $this->entityExtractor->pack($entity);
         array_push($headers, 'POST /HTTP/1.1');
         $this->curl->setHeaders($headers)->setPost($entityXml->asXML())->exec($this->routes->getEntityUrl($entity->getTypePluralized()));
         $xml = simplexml_load_string($this->curl->getResult());
     } else {
         $entityXml = $this->entityExtractor->pack($entity, $this->parametersManager->getEntityEditableParameters($entity));
         if ($this->entityLocker->isEntityLocked($entity)) {
             if (!$this->entityLocker->isEntityLockedByMe($entity)) {
                 throw new AlmEntityManagerException('Entity is locked by someone');
             }
         } else {
             $this->entityLocker->lockEntity($entity);
         }
         if ($this->isEntityVersioning($entity)) {
             $this->getEntityLocker()->checkOutEntity($entity);
         }
         array_push($headers, 'PUT /HTTP/1.1');
         $this->curl->setHeaders($headers)->setPut($entityXml->asXML())->exec($this->routes->getEntityUrl($entity->getTypePluralized(), $entity->id));
         $xml = simplexml_load_string($this->curl->getResult());
         if ($this->isEntityVersioning($entity)) {
             $this->getEntityLocker()->checkInEntity($entity);
         }
         $this->entityLocker->unlockEntity($entity);
     }
     return $this->entityExtractor->extract($xml);
 }
 /**
  * @throws AlmEntityParametersManagerException
  * @throws Exception\AlmCurlException
  * @throws Exception\AlmException
  */
 protected function refreshLists()
 {
     $this->curl->exec($this->routes->getListsUrl());
     $xml = simplexml_load_string($this->curl->getResult());
     if (false === $xml) {
         throw new AlmEntityParametersManagerException('Cannot get lists data');
     }
     $this->lists = $xml;
 }