You are here

public function Content::updateStatus in GatherContent 8

Same name and namespace in other branches
  1. 8.3 src/DAO/Content.php \Drupal\gathercontent\DAO\Content::updateStatus()

Update status of content.

Parameters

int $content_id: ID of content we want to update.

int $status_id: Status ID.

Return value

bool Return TRUE on success.

File

src/DAO/Content.php, line 71
Contains GatherContent\Accont class.

Class

Content
Class Account.

Namespace

Drupal\gathercontent\DAO

Code

public function updateStatus($content_id, $status_id) {
  try {
    $response = $this->client
      ->post('/items/' . $content_id . '/choose_status', array(
      'body' => array(
        'status_id' => $status_id,
      ),
    ));
    if ($response
      ->getStatusCode() === 202) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  } catch (\Exception $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
    \Drupal::logger('gathercontent')
      ->error($e
      ->getMessage(), array());
    return FALSE;
  }
}