You are here

public function Vcl::prepare_condition in Fastly 7.2

Prepares condition for insertion.

Return value

array|bool

1 call to Vcl::prepare_condition()
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 391

Class

Vcl
Class to control the VCL handling.

Code

public function prepare_condition() {

  // Prepare condition content.
  $requests = array();
  foreach ($this->_condition_data as $single_condition_data) {
    if (empty($single_condition_data['name']) || empty($single_condition_data['statement']) || empty($single_condition_data['type']) || empty($single_condition_data['priority'])) {
      $this
        ->add_error(t('Condition data not properly set.'));
      return FALSE;
    }
    else {
      if ($this
        ->get_condition($single_condition_data['name'])) {
        $requests[] = $this
          ->prepare_update_condition($single_condition_data);
      }
      else {

        // Do insert here because condition is needed before setting (requests are not sent in order)
        return $this
          ->insert_condition($single_condition_data);
      }
    }
  }
  return $requests;
}