bundles/Abcpremium/InspectablePdfsBundle/src/Event/AddInspectableSettingToProcessingConfig.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Abcpremium\InspectablePdfsBundle\Event;
  4. use Abcpremium\InspectablePdfsBundle\Model\Setting;
  5. use Pimcore\Event\DocumentEvents;
  6. use Pimcore\Event\Model\PrintConfigEvent;
  7. use Pimcore\Web2Print\Processor\PdfReactor;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class AddInspectableSettingToProcessingConfig implements EventSubscriberInterface
  10. {
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [
  14.             DocumentEvents::PRINT_MODIFY_PROCESSING_CONFIG => 'addInspectableSetting',
  15.         ];
  16.     }
  17.     public function addInspectableSetting(PrintConfigEvent $event): void
  18.     {
  19.         $processor $event->getProcessor();
  20.         if (!$processor instanceof PdfReactor) {
  21.             return;
  22.         }
  23.         $options $event->getArgument('config');
  24.         $optionArray get_object_vars($options);
  25.         $createInspectablePdf $optionArray[Setting::INSPECTABLE_PDF] ?? false;
  26.         if (false === $createInspectablePdf) {
  27.             return;
  28.         }
  29.         $config $event->getArgument('reactorConfig');
  30.         $config['inspectableSettings'] = [
  31.             'enabled' => true,
  32.         ];
  33.         $event->setArgument('reactorConfig'$config);
  34.     }
  35. }