vendor/pimcore/data-hub-file-export/src/EventSubscriber/ConfigurationEventSubscriber.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under following license:
  6.  * - Pimcore Commercial License (PCL)
  7.  *
  8.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  9.  *  @license    http://www.pimcore.org/license     PCL
  10.  */
  11. namespace Pimcore\Bundle\DataHubFileExportBundle\EventSubscriber;
  12. use Pimcore\Bundle\DataHubBundle\Configuration;
  13. use Pimcore\Bundle\DataHubBundle\Event\ConfigurationEvents;
  14. use Pimcore\Bundle\DataHubFileExportBundle\Exporter\File;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface as EventSubscriberInterfaceAlias;
  16. use Symfony\Component\EventDispatcher\GenericEvent;
  17. class ConfigurationEventSubscriber implements EventSubscriberInterfaceAlias
  18. {
  19.     /**
  20.      * @return string[]
  21.      */
  22.     public static function getSubscribedEvents()
  23.     {
  24.         return [
  25.             ConfigurationEvents::CONFIGURATION_POST_DELETE => 'postDelete'
  26.         ];
  27.     }
  28.     public function postDelete(GenericEvent $event)
  29.     {
  30.         /**
  31.          * @var Configuration $config
  32.          */
  33.         $config $event->getSubject();
  34.         if ($config->getType() === 'fileExport') {
  35.             $name $config->getName();
  36.             $downloadFile PIMCORE_PRIVATE_VAR '/data-hub/file-export/' $name '.out';
  37.             if (file_exists($downloadFile)) {
  38.                 unlink($downloadFile);
  39.             }
  40.             $exporter \Pimcore\Bundle\DataHubFileExportBundle\Helper::getExporterService($config);
  41.             if ($exporter instanceof File) {
  42.                 $folder $exporter->getExporter()->getTmpDir();
  43.                 if (is_dir($folder)) {
  44.                     rmdir($folder);
  45.                 }
  46.             }
  47.         }
  48.     }
  49. }