<?php
declare(strict_types=1);
namespace Abcpremium\InspectablePdfsBundle\Event;
use Abcpremium\InspectablePdfsBundle\Model\Setting;
use Pimcore\Event\DocumentEvents;
use Pimcore\Event\Model\PrintConfigEvent;
use Pimcore\Web2Print\Processor\PdfReactor;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AddInspectableSettingToProccessingOptions implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
DocumentEvents::PRINT_MODIFY_PROCESSING_OPTIONS => 'addInspectableSetting',
];
}
public function addInspectableSetting(PrintConfigEvent $event): void
{
$processor = $event->getProcessor();
if (!$processor instanceof PdfReactor) {
return;
}
$options = $event->getArgument('options');
$options[] = [
'name' => Setting::INSPECTABLE_PDF,
'type' => 'bool',
'default' => false,
];
$event->setArgument('options', $options);
}
}