Esempio n. 1
0
 /**
  * Constructor
  *
  * @param \Cake\Network\Request $request Request instance.
  * @param \Cake\Network\Response $response Response instance.
  * @param \Cake\Event\EventManager $eventManager Event manager instance.
  * @param array $viewOptions View options. See View::$_passedVars for list of
  *   options which get set as class properties.
  *
  * @throws \Cake\Core\Exception\Exception
  */
 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     $this->_passedVars[] = 'pdfConfig';
     parent::__construct($request, $response, $eventManager, $viewOptions);
     $this->pdfConfig = array_merge((array) Configure::read('CakePdf'), (array) $this->pdfConfig);
     $response->type('pdf');
     if (isset($viewOptions['name']) && $viewOptions['name'] === 'Error') {
         $this->subDir = null;
         $this->layoutPath = null;
         $response->type('html');
         return;
     }
     if (!$this->pdfConfig) {
         throw new Exception(__d('cakepdf', 'Controller attribute $pdfConfig is not correct or missing'));
     }
     $this->renderer($this->pdfConfig);
 }
 /**
  * @param \Cake\Network\Request|null $request Request instance.
  * @param \Cake\Network\Response|null $response Response instance.
  * @param \Cake\Event\EventManager|null $eventManager Event manager instance.
  * @param array $viewOptions View options.
  */
 public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
 {
     parent::__construct($request, $response, $eventManager, $viewOptions);
     $this->_duration = isset($viewOptions['duration']) ? $viewOptions['duration'] : 0;
     $this->_compress = isset($viewOptions['compress']) ? $viewOptions['compress'] : false;
 }