diff --git a/app/AppKernel.php b/app/AppKernel.php index 867720e..b915e32 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -22,6 +22,7 @@ class AppKernel extends Kernel // 3rd party bundles new Ivory\CKEditorBundle\IvoryCKEditorBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), + new Io\TcpdfBundle\IoTcpdfBundle(), // Own bundles new KekRozsak\FrontBundle\KekRozsakFrontBundle(), new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(), diff --git a/app/config/config.yml b/app/config/config.yml index 3cdf60a..e8e0515 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -8,7 +8,6 @@ framework: secret: %secret% router: resource: "%kernel.root_dir%/config/routing.yml" - strict_parameters: %kernel.debug% form: true csrf_protection: true validation: { enable_annotations: true } diff --git a/composer.json b/composer.json index 23109e0..68b6f95 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,12 @@ "autoload": { "psr-0": { "": "src/" } }, + "repositories": [ + { + "type": "vcs", + "url": "http://github.com/w00d5t0ck/IoTcpdfBundle" + } + ], "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", @@ -19,7 +25,8 @@ "jms/security-extra-bundle": "1.1.*", "jms/di-extra-bundle": "1.0.*", "doctrine/doctrine-migrations-bundle": "dev-master", - "egeloen/ckeditor-bundle": "dev-master" + "egeloen/ckeditor-bundle": "dev-master", + "gergelypolonkai/tcpdfbundle": "dev-master" }, "scripts": { "post-install-cmd": [ diff --git a/src/KekRozsak/FrontBundle/Controller/DocumentController.php b/src/KekRozsak/FrontBundle/Controller/DocumentController.php index 02240a8..7f63356 100644 --- a/src/KekRozsak/FrontBundle/Controller/DocumentController.php +++ b/src/KekRozsak/FrontBundle/Controller/DocumentController.php @@ -14,15 +14,23 @@ use KekRozsak\FrontBundle\Extensions\Slugifier; class DocumentController extends Controller { /** - * @Route("/dokumentum/{slug}", name="KekRozsakFrontBundle_documentView") + * @Route("/dokumentum/{slug}.{_format}", name="KekRozsakFrontBundle_documentView", defaults={"_format": "html"}, requirements={"_format": "html|pdf"}) * @Template() * @ParamConverter("document") */ - public function viewAction(Document $document) + public function viewAction(Document $document, $_format) { - return array( + $templateParams = array( 'document' => $document, ); + + if ($_format == 'pdf') + { + $html = $this->renderView('KekRozsakFrontBundle:Document:pdfView.html.twig', $templateParams); + return $this->get('io_tcpdf')->quick_pdf($html); + } + + return $templateParams; } /** diff --git a/src/KekRozsak/FrontBundle/Resources/views/Document/pdfView.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Document/pdfView.html.twig new file mode 100644 index 0000000..f050aac --- /dev/null +++ b/src/KekRozsak/FrontBundle/Resources/views/Document/pdfView.html.twig @@ -0,0 +1,5 @@ +{# vim: ft=htmljinja +#} +

{{ document.title }}

+

Írta: {{ document.createdBy.displayName }}

+{{ document.content|raw }}