vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/PricingManager/Condition/Token.php line 36

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Bundle\EcommerceFrameworkBundle\PricingManager\Condition;
  15. use Pimcore\Bundle\EcommerceFrameworkBundle\PricingManager\ConditionInterface;
  16. use Pimcore\Bundle\EcommerceFrameworkBundle\PricingManager\EnvironmentInterface;
  17. /**
  18.  * @deprecated will be removed in Pimcore 11
  19.  */
  20. class Token implements ConditionInterface
  21. {
  22.     /**
  23.      * @var string
  24.      */
  25.     protected $token;
  26.     /**
  27.      * @param EnvironmentInterface $environment
  28.      *
  29.      * @return bool
  30.      */
  31.     public function check(EnvironmentInterface $environment)
  32.     {
  33.         trigger_deprecation(
  34.             'pimcore/pimcore',
  35.             '10.5',
  36.             sprintf('%s is deprecated. It will be removed in Pimcore 11.'__CLASS__)
  37.         );
  38.         $token $environment->getSession()->get('token');
  39.         return $token === $this->getToken();
  40.     }
  41.     /**
  42.      * @return string
  43.      */
  44.     public function toJSON()
  45.     {
  46.         trigger_deprecation(
  47.             'pimcore/pimcore',
  48.             '10.5',
  49.             sprintf('%s is deprecated. It will be removed in Pimcore 11.'__CLASS__)
  50.         );
  51.         // basic
  52.         $json = [
  53.             'type' => 'Token''token' => $this->getToken(),
  54.         ];
  55.         return json_encode($json);
  56.     }
  57.     /**
  58.      * @param string $string
  59.      *
  60.      * @return ConditionInterface
  61.      */
  62.     public function fromJSON($string)
  63.     {
  64.         trigger_deprecation(
  65.             'pimcore/pimcore',
  66.             '10.5',
  67.             sprintf('%s is deprecated. It will be removed in Pimcore 11.'__CLASS__)
  68.         );
  69.         $json json_decode($string);
  70.         $this->setToken($json->token);
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return string
  75.      */
  76.     public function getToken()
  77.     {
  78.         return $this->token;
  79.     }
  80.     /**
  81.      * @param string $token
  82.      */
  83.     public function setToken($token)
  84.     {
  85.         $this->token $token;
  86.     }
  87. }