public function __construct(array $initParams)
 {
     if (!isset($initParams["PARENT_ID"])) {
         throw new ArgumentNullException('initParams["PARENT_ID"]');
     }
     $this->parentAutomatic = Manager::getService($initParams["PARENT_ID"]);
     if (!$this->parentAutomatic || !$this->parentAutomatic instanceof Automatic) {
         throw new SystemException("Can't initialize AutomaticProfile's id: " . $initParams["ID"] . " parent Automatic parent_id: " . $initParams["PARENT_ID"]);
     }
     $this->parentSid = $this->parentAutomatic->getSid();
     if (strlen($this->parentSid) <= 0) {
         throw new SystemException("Can't determine AutomaticProfile's SID. profile id: " . $initParams["ID"] . " parent Automatic id: " . $initParams["PARENT_ID"]);
     }
     $this->parentHandlerInitParams = $this->parentAutomatic->getHandlerInitParams($this->parentSid);
     if ($this->parentHandlerInitParams === false) {
         throw new SystemException("Can't get init services params of Automatic delivery service with sid: " . $this->parentSid);
     }
     parent::__construct($initParams);
     if (isset($this->config["MAIN"]["PROFILE_ID"])) {
         $this->profileId = $this->config["MAIN"]["PROFILE_ID"];
     }
     if (strlen($this->profileId) > 0 && !array_key_exists($this->profileId, $this->parentHandlerInitParams["PROFILES"])) {
         throw new SystemException("Profile \"" . $this->profileId . "\" is not part of Automatic delivery service with sid: " . $this->parentSid);
     }
     $this->inheritParams();
 }
Exemple #2
0
 public function __construct(array $initParams)
 {
     parent::__construct($initParams);
     if (isset($this->config["MAIN"]["SID"]) && strlen($this->config["MAIN"]["SID"]) > 0) {
         $initedHandlers = self::getRegisteredHandlers("SID");
         if (!isset($initedHandlers[$this->config["MAIN"]["SID"]])) {
             throw new SystemException("Can't initialize service with code\"" . $this->config["MAIN"]["SID"] . "\"");
         }
         $this->sid = $this->code = $this->config["MAIN"]["SID"];
         $this->handlerInitParams = $this->getHandlerInitParams($this->sid);
         if (!empty($this->handlerInitParams["TRACKING_CLASS_NAME"])) {
             $this->setTrackingClass($this->handlerInitParams["TRACKING_CLASS_NAME"]);
         }
         if ($this->handlerInitParams == false) {
             throw new SystemException("Can't get delivery services init params. Delivery id: " . $this->id . ", sid: " . $this->sid);
         }
         if (strlen($this->currency) <= 0 && !empty($this->handlerInitParams["BASE_CURRENCY"])) {
             $this->currency = $this->handlerInitParams["BASE_CURRENCY"];
         }
     }
     $initParams = self::convertNewServiceToOld($initParams, $this->sid);
     if (isset($initParams["CONFIG"])) {
         $this->oldConfig = $initParams["CONFIG"];
     }
 }
Exemple #3
0
 public function __construct(array $initParams)
 {
     if (!isset($initParams["ACTIVE"])) {
         $initParams["ACTIVE"] = "Y";
     }
     $initParams["CONFIG"] = array();
     parent::__construct($initParams);
 }
Exemple #4
0
 /**
  * @param array $initParams
  * @throws \Bitrix\Main\ArgumentTypeException
  */
 public function __construct(array $initParams)
 {
     parent::__construct($initParams);
     //Default value
     if (!isset($this->config["MAIN"]["0"])) {
         $this->config["MAIN"]["0"] = "0";
     }
 }
Exemple #5
0
 /**
  * @param array $initParams Initial data params from table record.
  * @throws \Bitrix\Main\ArgumentNullException
  * @throws \Bitrix\Main\ArgumentTypeException
  */
 public function __construct(array $initParams)
 {
     parent::__construct($initParams);
     if (!isset($this->config["MAIN"]["PRICE"])) {
         $this->config["MAIN"]["PRICE"] = "0";
     }
     if (!isset($initParams["CURRENCY"])) {
         $initParams["CURRENCY"] = "RUB";
     }
     if (!isset($this->config["MAIN"]["PERIOD"]) || !is_array($this->config["MAIN"]["PERIOD"])) {
         $this->config["MAIN"]["PERIOD"] = array();
         $this->config["MAIN"]["PERIOD"]["FROM"] = "0";
         $this->config["MAIN"]["PERIOD"]["TO"] = "0";
         $this->config["MAIN"]["PERIOD"]["TYPE"] = "D";
     }
 }