You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

* Class to dispatch the zipped file with the given method
* @author Shikiryu
class FileToZipDispatcher{
private $_method = array();
private $_zip;
public function __construct(array $method, FileToZip $zip){
$this->_method = $method;
$this->_zip = $zip;
public function dispatch($options){
foreach($this->_method as $method){
if(method_exists($this, '_'.$method)) {
return call_user_func(array($this, '_'.$method), $options);
throw new Exception(sprintf('The required method "%s" does not exist for %s', $method, get_class($this)));
if(!in_array('toDownloadLater', $this->_method)){
private function _toDownloadNow($options){
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=".$this->_zip->getFinalFileName());
header("Pragma: no-cache");
header("Expires: 0");
private function _toDownloadLater($options){
$index = new ToDownloadIndex();
$shortcut = $index->saveNewLine($this->_zip->getFinalFileName());
$email = new FileToZipEmail($options['email'], $shortcut);