public function __construct(array $initParams) { if (!isset($initParams["ACTIVE"])) { $initParams["ACTIVE"] = "Y"; } $initParams["CONFIG"] = array(); parent::__construct($initParams); }
/** * @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"; } }
public function prepareFieldsForSaving(array $fields) { $fields = parent::prepareFieldsForSaving($fields); if (!isset($fields["CONFIG"])) { return $fields; } if (!isset($fields["CONFIG"]["MAIN"]["SID"]) || strlen($fields["CONFIG"]["MAIN"]["SID"]) <= 0) { throw new SystemException(Loc::getMessage("SALE_DLVR_HANDL_AUT_ERROR_HANDLER")); } if (strlen($this->sid) <= 0) { return $fields; } $fields["CODE"] = $this->sid; $configMain = $fields["CONFIG"]["MAIN"]; if (isset($this->handlerInitParams["DBSETSETTINGS"]) && is_callable($this->handlerInitParams["DBSETSETTINGS"])) { $oldSettings = $fields["CONFIG"]; unset($oldSettings["MAIN"]); $oldSettings = self::convertNewSettingsToOld($oldSettings); if (!($strOldSettings = call_user_func($this->handlerInitParams["DBSETSETTINGS"], $oldSettings))) { throw new SystemException("Can't save delivery services's old settings"); } } else { $strOldSettings = ""; } $strOldSettings = serialize($strOldSettings); $fields["CONFIG"] = array("MAIN" => $configMain); $fields["CONFIG"]["MAIN"]["OLD_SETTINGS"] = $strOldSettings; if (isset($this->handlerInitParams["CURRENCY"]) && strlen($this->handlerInitParams["CURRENCY"]) > 0) { $fields["CURRENCY"] = $this->handlerInitParams["CURRENCY"]; } return $fields; }
/** * @param Delivery\Services\Base $deliveryService * @throws Main\NotSupportedException */ public function setDeliveryService(Delivery\Services\Base $deliveryService) { $this->deliveryService = $deliveryService; $this->setField("DELIVERY_ID", $deliveryService->getId()); }
public function prepareFieldsForSaving(array $fields) { $parentAutoConfig = $this->parentAutomatic->getConfigValues(); if (isset($fields["CONFIG"]) && is_array($fields["CONFIG"])) { $fields["CONFIG"] = array_merge($parentAutoConfig, $fields["CONFIG"]); } $configMain = $fields["CONFIG"]["MAIN"]; $handler = $this->parentHandlerInitParams; if (isset($handler["DBSETSETTINGS"]) && is_callable($handler["DBSETSETTINGS"])) { $oldSettings = $fields["CONFIG"]; unset($oldSettings["MAIN"]); if (is_array($oldSettings)) { $oldSettings = Automatic::convertNewSettingsToOld($oldSettings); } if (!($strOldSettings = call_user_func($handler["DBSETSETTINGS"], $oldSettings))) { throw new SystemException("Can't save delivery services's old settings"); } } else { $strOldSettings = ""; } $strOldSettings = serialize($strOldSettings); $fields["CONFIG"] = array("MAIN" => $configMain); $fields["CONFIG"]["MAIN"]["OLD_SETTINGS"] = $strOldSettings; $fields = parent::prepareFieldsForSaving($fields); $fields["CODE"] = $this->parentAutomatic->getSid() . ":" . $this->profileId; return $fields; }
public function prepareFieldsForSaving(array $fields) { if ((!isset($fields["CODE"]) || intval($fields["CODE"]) < 0) && isset($fields["ID"]) && intval($fields["ID"]) > 0) { $fields["CODE"] = $fields["ID"]; } return parent::prepareFieldsForSaving($fields); }