You are here

public function Vcl::__construct in Fastly 7.2

Sets data to be processed, sets Credentials VclHandler constructor.

File

./fastly.vcl.inc, line 77

Class

Vcl
Class to control the VCL handling.

Code

public function __construct($data, $api_key, $service_id) {
  $this->_webhook = fastly_get_webhook();
  $this->_api_key = $api_key;
  $this->_service_id = $service_id;
  $this->_hostname = 'https://api.fastly.com/';
  $this->_api = fastly_get_api($this->_api_key, $this->_service_id);
  $this->_vcl_data = !empty($data['vcl']) ? $data['vcl'] : FALSE;
  $this->_condition_data = !empty($data['condition']) ? $data['condition'] : FALSE;
  $this->_setting_data = !empty($data['setting']) ? $data['setting'] : FALSE;
  $this->_response_object_data = !empty($data['response']) ? $data['response'] : FALSE;

  // Set credentials based data (API url, headers, last version)
  $this->_version_base_url = 'service/' . $this->_service_id . '/version';
  $this->_headers_get = array(
    'Fastly-Key' => $this->_api_key,
    'Accept' => 'application/json',
  );
  $this->_headers_post = array(
    'Fastly-Key' => $this->_api_key,
    'Accept' => 'application/json',
    'Content-Type' => 'application/x-www-form-urlencoded',
  );
  $this->_last_version_data = $this
    ->get_last_version();
  if ($this->_last_version_data) {
    $this->_last_active_version_num = $this->_last_version_data->number;
  }
  return;
}