Exemplo n.º 1
0
 /**
  * Updates a ticket and resets the ticket entity with the returned field values.
  * @see \Malwarebytes\ZendeskBundle\DataModel\AbstractRepository::_create()
  * @param AbstractEntity $instance
  * @return Entity
  */
 protected function _update(AbstractEntity $instance)
 {
     $response = $this->_apiService->updateTicket($instance['id'], $instance->toArray());
     if (!empty($response['ticket'])) {
         $instance->setFields($response['ticket'], true);
     }
     return $instance;
 }
Exemplo n.º 2
0
 /**
  * Makes the appropriate API call with the instance data
  * @see \Malwarebytes\ZendeskBundle\DataModel\AbstractRepository::_update()
  * @param Entity $instance
  * @return $instance
  */
 protected function _update(AbstractEntity $instance)
 {
     $response = $this->_apiService->updateGroup($instance['id'], $instance->toArray());
     if ($response['group']) {
         $instance->setFields($response['group']);
     }
     return $instance;
 }
 /**
  * Strategy for creating or updating instance.
  * @param AbstractEntity $instance
  * @return AbstractEntity
  */
 public function save(AbstractEntity $instance)
 {
     if ($instance->exists()) {
         if ($instance->isIncomplete()) {
             throw new \Exception('Violated integrity check for completeness on existing instance.');
         }
         return $this->_update($instance);
     } else {
         return $this->_create($instance);
     }
 }