You are here

public function Vcl::prepare_setting in Fastly 7.2

Prepares setting for insertion.

Return value

array|bool

1 call to Vcl::prepare_setting()
Vcl::execute in ./fastly.vcl.inc
Main execute function, takes values inserted into constructor, builds requests and sends them via Fastly API.

File

./fastly.vcl.inc, line 481

Class

Vcl
Class to control the VCL handling.

Code

public function prepare_setting() {

  // Prepare setting content.
  $requests = array();
  foreach ($this->_setting_data as $single_setting_data) {
    if (empty($single_setting_data['name']) || empty($single_setting_data['action']) || empty($single_setting_data['request_condition'])) {
      $this
        ->add_error(t('Setting data not properly set.'));
      return FALSE;
    }
    else {
      if ($this
        ->get_setting($single_setting_data['name'])) {
        $requests[] = $this
          ->prepare_update_setting($single_setting_data);
      }
      else {
        $requests[] = $this
          ->prepare_insert_setting($single_setting_data);
      }
    }
  }
  return $requests;
}