vendor/pimcore/pimcore/bundles/CoreBundle/EventListener/DumpTranslationEntriesListener.php line 65

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Commercial License (PCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  14.  */
  15. namespace Pimcore\Bundle\CoreBundle\EventListener;
  16. use Pimcore\Translation\TranslationEntriesDumper;
  17. use Symfony\Component\Console\ConsoleEvents;
  18. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  19. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  20. use Symfony\Component\HttpKernel\Event\TerminateEvent;
  21. use Symfony\Component\HttpKernel\KernelEvents;
  22. /**
  23.  * @internal
  24.  */
  25. class DumpTranslationEntriesListener implements EventSubscriberInterface
  26. {
  27.     /** @var TranslationEntriesDumper */
  28.     private TranslationEntriesDumper $dumper;
  29.     /**
  30.      * @param TranslationEntriesDumper $dumper
  31.      */
  32.     public function __construct(TranslationEntriesDumper $dumper)
  33.     {
  34.         $this->dumper $dumper;
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     public static function getSubscribedEvents()
  40.     {
  41.         return [
  42.             KernelEvents::TERMINATE => 'onKernelTerminate',
  43.             ConsoleEvents::TERMINATE => 'onConsoleTerminate',
  44.         ];
  45.     }
  46.     /**
  47.      * @param TerminateEvent $event
  48.      */
  49.     public function onKernelTerminate(TerminateEvent $event)
  50.     {
  51.         $this->dumper->dumpToDb();
  52.     }
  53.     /**
  54.      * @param ConsoleTerminateEvent $event
  55.      */
  56.     public function onConsoleTerminate(ConsoleTerminateEvent $event)
  57.     {
  58.         $this->dumper->dumpToDb();
  59.     }
  60. }