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

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.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             ConfigurationEvents::CONFIGURATION_POST_DELETE => 'postDelete'
  23.         ];
  24.     }
  25.     /**
  26.      * @param GenericEvent $event
  27.      *
  28.      * @throws \Doctrine\DBAL\DBALException
  29.      */
  30.     public function postDelete(GenericEvent $event)
  31.     {
  32.         /**
  33.          * @var $config Configuration
  34.          */
  35.         $config $event->getSubject();
  36.         if ($config->getType() === 'fileExport') {
  37.             $name $config->getName();
  38.             $downloadFile PIMCORE_PRIVATE_VAR '/data-hub/file-export/' $name '.out';
  39.             if (file_exists($downloadFile)) {
  40.                 unlink($downloadFile);
  41.             }
  42.             $exporter \Pimcore\Bundle\DataHubFileExportBundle\Helper::getExporterService($config);
  43.             if ($exporter instanceof File) {
  44.                 $folder $exporter->getExporter()->getTmpDir();
  45.                 if (is_dir($folder)) {
  46.                     rmdir($folder);
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }