local/modules/PayPal/Hook/BackHookManager.php line 44

  1. <?php
  2. /*************************************************************************************/
  3. /*                                                                                   */
  4. /*      Thelia                                                                         */
  5. /*                                                                                   */
  6. /*      Copyright (c) OpenStudio                                                     */
  7. /*      email : info@thelia.net                                                      */
  8. /*      web : http://www.thelia.net                                                  */
  9. /*                                                                                   */
  10. /*      This program is free software; you can redistribute it and/or modify         */
  11. /*      it under the terms of the GNU General Public License as published by         */
  12. /*      the Free Software Foundation; either version 3 of the License                */
  13. /*                                                                                   */
  14. /*      This program is distributed in the hope that it will be useful,              */
  15. /*      but WITHOUT ANY WARRANTY; without even the implied warranty of               */
  16. /*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
  17. /*      GNU General Public License for more details.                                 */
  18. /*                                                                                   */
  19. /*      You should have received a copy of the GNU General Public License            */
  20. /*        along with this program. If not, see <http://www.gnu.org/licenses/>.         */
  21. /*                                                                                   */
  22. /*************************************************************************************/
  23. namespace PayPal\Hook;
  24. use PayPal\Model\PaypalOrderQuery;
  25. use PayPal\PayPal;
  26. use PayPal\Service\Base\PayPalBaseService;
  27. use Thelia\Core\Event\Hook\HookRenderEvent;
  28. use Thelia\Core\Hook\BaseHook;
  29. use Thelia\Model\ModuleConfig;
  30. use Thelia\Model\ModuleConfigQuery;
  31. /**
  32.  * Class BackHookManager
  33.  * @package PayPal\Hook
  34.  */
  35. class BackHookManager extends BaseHook
  36. {
  37.     /**
  38.      * @param HookRenderEvent $event
  39.      */
  40.     public function onModuleConfigure(HookRenderEvent $event)
  41.     {
  42.         $vars = [];
  43.         if (null !== $moduleConfigs ModuleConfigQuery::create()->findByModuleId(PayPal::getModuleId())) {
  44.             /** @var ModuleConfig $moduleConfig */
  45.             foreach ($moduleConfigs as $moduleConfig) {
  46.                 $vars$moduleConfig->getName() ] = $moduleConfig->getValue();
  47.             }
  48.         }
  49.         $vars['paypal_appid'] = PayPalBaseService::getLogin();
  50.         $vars['paypal_authend'] = PayPalBaseService::getMode();
  51.         $event->add(
  52.             $this->render('paypal/module-configuration.html'$vars)
  53.         );
  54.     }
  55.     /**
  56.      * @param HookRenderEvent $event
  57.      */
  58.     public function onOrderEditPaymentModuleBottom(HookRenderEvent $event)
  59.     {
  60.         $templateData $event->getArguments();
  61.         if (null !== $payPalOrder PaypalOrderQuery::create()->findOneById($event->getArgument('order_id'))) {
  62.             $event->add(
  63.                 $this->render(
  64.                     'paypal/payment-information.html',
  65.                     $templateData
  66.                 )
  67.             );
  68.         }
  69.     }
  70.     /**
  71.      * @param HookRenderEvent $event
  72.      */
  73.     public function onOrderEditJs(HookRenderEvent $event)
  74.     {
  75.         $templateData $event->getArguments();
  76.         if (null !== $payPalOrder PaypalOrderQuery::create()->findOneById($event->getArgument('order_id'))) {
  77.             $event->add(
  78.                 $this->render(
  79.                     'paypal/order-edit-js.html',
  80.                     $templateData
  81.                 )
  82.             );
  83.         }
  84.     }
  85. }