Last active
June 1, 2017 07:17
-
-
Save tippexs/3c353f02ead2cd51a0d7f2277d674107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller\Admin; | |
use Cake\Core\Configure; | |
use App\Controller\AppController; | |
use Cake\ORM\TableRegistry; | |
use Cake\Utility\Hash; | |
Configure::write('CakePdf', [ | |
'engine' => 'CakePdf.WkHtmlToPdf', | |
'margin' => [ | |
'bottom' => 15, | |
'left' => 50, | |
'right' => 30, | |
'top' => 45 | |
], | |
'orientation' => 'landscape', | |
'download' => true | |
]); | |
class DaylistsController extends AppController | |
{ | |
public $uses = false; | |
public function initialize() | |
{ | |
parent::initialize(); // TODO: Change the autogenerated stub | |
$this->loadComponent('RequestHandler'); | |
} | |
public function view ($id = null) { | |
$this->viewBuilder()->options([ | |
'pdfConfig' => [ | |
'orientation' => 'portrait', | |
'filename' => 'Liste' . $id | |
] | |
]); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Routes configuration | |
* | |
* In this file, you set up routes to your controllers and their actions. | |
* Routes are very important mechanism that allows you to freely connect | |
* different URLs to chosen controllers and their actions (functions). | |
* | |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | |
* | |
* Licensed under The MIT License | |
* For full copyright and license information, please see the LICENSE.txt | |
* Redistributions of files must retain the above copyright notice. | |
* | |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | |
* @link http://cakephp.org CakePHP(tm) Project | |
* @license http://www.opensource.org/licenses/mit-license.php MIT License | |
*/ | |
use Cake\Core\Plugin; | |
use Cake\Routing\RouteBuilder; | |
use Cake\Routing\Router; | |
use Cake\Routing\Route\DashedRoute; | |
Router::defaultRouteClass(DashedRoute::class); | |
Router::extensions(['pdf']); | |
Router::scope('/', function (RouteBuilder $routes) { | |
$routes->connect('/', ['prefix' => 'admin', 'controller' => 'Dashboard', 'action' => 'index']); | |
$routes->connect('/admin', ['prefix' => 'admin', 'controller' => 'Dashboard', 'action' => 'index']); | |
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']); | |
$routes->fallbacks(DashedRoute::class); | |
}); | |
Router::prefix('admin', function ($routes) { | |
$routes->connect('/:controller', ['action' => 'index']); | |
$routes->connect('/:controller/:action/*', []); | |
$routes->fallbacks('DashedRoute'); | |
}); | |
Plugin::routes(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment