public function VclHandler::prepareVcl in Fastly 8.3
Prepares VCL request.
Return value
array|bool Request date for VCL request, FALSE if not valid.
1 call to VclHandler::prepareVcl()
- VclHandler::execute in src/
VclHandler.php - Main execute function.
File
- src/
VclHandler.php, line 595
Class
- VclHandler
- Class to control the VCL handling.
Namespace
Drupal\fastlyCode
public function prepareVcl() {
// Prepare VCL data content.
$requests = [];
foreach ($this->vclData as $single_vcl_data) {
if (!empty($single_vcl_data['type'])) {
$single_vcl_data['name'] = 'drupalmodule_' . $single_vcl_data['type'];
$single_vcl_data['dynamic'] = 0;
$single_vcl_data['priority'] = 50;
if (file_exists($single_vcl_data['vcl_dir'] . '/' . $single_vcl_data['type'] . '.vcl')) {
$single_vcl_data['content'] = file_get_contents($single_vcl_data['vcl_dir'] . '/' . $single_vcl_data['type'] . '.vcl');
unset($single_vcl_data['vcl_dir']);
}
else {
$message = $this
->t('VCL file does not exist.');
$this
->addError($message);
$this->logger
->info($message);
return FALSE;
}
if ($this
->checkIfVclExists($single_vcl_data['name'])) {
$requests[] = $this
->prepareUpdateVcl($single_vcl_data);
}
else {
$requests[] = $this
->prepareInsertVcl($single_vcl_data);
}
}
else {
$message = $this
->t('VCL type not set.');
$this
->addError($message);
$this->logger
->info($message);
return FALSE;
}
}
return $requests;
}