headers->add([ 'X-Sendfile-Type' => 'X-SendFile', ]); } /** * {@inheritdoc} */ public function setMapping(array $mapping) { $final = []; foreach ($mapping as $entry) { if (!is_array($entry)) { throw new InvalidArgumentException('XSendFile mapping entry must be an array'); } if (!isset($entry['directory'])) { throw new InvalidArgumentException('XSendFile mapping entry must contain at least a "directory" key'); } if (false === is_dir(trim($entry['directory']))) { continue; } $final[] = [ 'directory' => $this->sanitizePath(realpath($entry['directory'])) ]; } $this->mapping = $final; } /** * {@inheritdoc} */ public function getVirtualHostConfiguration() { $output = "\n"; $output .= "\n"; $output .= " \n"; $output .= " XSendFile on\n"; foreach ($this->mapping as $entry) { $output .= ' XSendFilePath ' . $entry['directory'] . "\n"; } $output .= " \n"; $output .= "\n"; return $output; } }