local/modules/Colissimo/EventListener/AreaDeletedListener.php line 31

  1. <?php
  2. /*************************************************************************************/
  3. /*      This file is part of the Thelia package.                                     */
  4. /*                                                                                   */
  5. /*      Copyright (c) OpenStudio                                                     */
  6. /*      email : dev@thelia.net                                                       */
  7. /*      web : http://www.thelia.net                                                  */
  8. /*                                                                                   */
  9. /*      For the full copyright and license information, please view the LICENSE.txt  */
  10. /*      file that was distributed with this source code.                             */
  11. /*************************************************************************************/
  12. namespace Colissimo\EventListener;
  13. use Colissimo\Colissimo;
  14. use Colissimo\Model\Config\ColissimoConfigValue;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. use Thelia\Core\Event\Area\AreaDeleteEvent;
  17. use Thelia\Core\Event\TheliaEvents;
  18. /**
  19.  * Class AreaDeletedListener
  20.  * @package AreaDeletedListener\EventListener
  21.  * @author Thomas Arnaud <tarnaud@openstudio.fr>
  22.  */
  23. class AreaDeletedListener implements EventSubscriberInterface
  24. {
  25.     /**
  26.      * @param AreaDeleteEvent $event
  27.      */
  28.     public function updateConfig(AreaDeleteEvent $event)
  29.     {
  30.         if (null !== $data Colissimo::getConfigValue(ColissimoConfigValue::PRICESnull)) {
  31.             $areaId $event->getAreaId();
  32.             $json_data json_decode($datatrue);
  33.             unset($json_data[$areaId]);
  34.             Colissimo::setConfigValue(ColissimoConfigValue::PRICESjson_encode($json_datatrue));
  35.         }
  36.     }
  37.     /**
  38.      * @return array
  39.      */
  40.     public static function getSubscribedEvents()
  41.     {
  42.         return [
  43.             TheliaEvents::AREA_DELETE => [
  44.                 'updateConfig'128
  45.             ]
  46.         ];
  47.     }
  48. }