9. For programmers and developers
This section is aimed at programmers who want to influence this extension in their own modules. In the program flow, you can link in at various points using a HOOK registration. The extension contao-pdfforms-bundle calls the registered hooks, if any are available.
The following hooks are available:
pdf_formsBeforePdf
Is called after data preparation before the PDF is created. Here, further entries can be added to the $arrPDF array or existing entries can be modified. The hook must return the $arrPDF as the return value.
Example:
// src/EventListener/Pdf_formsBeforePdfListener.php
<?php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('pdf_formsBeforePdf')]
class Pdf_formsBeforePdfListener
{
public function __invoke(array $arrPDF)
{
// any code
return $arrPDF;
}
}
pdf_formsPositions
Is called up for each item in the form during PDF creation. It is still possible to manipulate data here. The page number cannot be changed, otherwise the output will not work correctly. The passed and possibly modified array $arrItem is expected as the return value.
Example:
// src/EventListener/Pdf_formsPositionsListener.php
<?php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('pdf_formsPositions')]
class Pdf_formsPositionsListener
{
public function __invoke(array $arrItem)
{
// any code
return $arrItem;
}
}
pdf_formsAfterPdf
Is called up after creation, saving and transfer to form processing. Further final activities can be inserted here using a hook. The hook has no return value.
Example:
// src/EventListener/Pdf_formsAfterPdfListener.php
<?php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('pdf_formsAfterPdf')]
class Pdf_formsAfterPdfListener
{
public function __invoke(string $pdfdatei, array $arrPDF): void
{
// any code
}
}
No comments to display
No comments to display