Static calls.

@param bool $safe
@param bool $setSettings
@param bool $mergeOldSettings
972677
public function _reindex($safe = true, $setSettings = true, $mergeOldSettings = false, \Closure $onInsert = null)
    {
        /** @var \AlgoliaSearch\Laravel\ModelHelper $modelHelper */
        $modelHelper = App::make('\AlgoliaSearch\Laravel\ModelHelper');

        $indices = $modelHelper->getIndices($this);
        $indicesTmp = $safe ? $modelHelper->getIndicesTmp($this) : $indices;

        if ($setSettings === true) {
            $setToTmpIndices = ($safe === true);
            $this->_setSettings($setToTmpIndices, $mergeOldSettings);
        }

        static::chunk(100, function ($models) use ($indicesTmp, $modelHelper, $onInsert) {
            /** @var \AlgoliaSearch\Index $index */
            foreach ($indicesTmp as $index) {
                $records         = [];
                $recordsAsEntity = [];

                foreach ($models as $model) {
                    if ($modelHelper->indexOnly($model, $index->indexName)) {
                        $records[] = $model->getAlgoliaRecordDefault($index->indexName);

                        if ($onInsert && is_callable($onInsert)) {
                            $recordsAsEntity[] = $model;
                        }
                    }
                }

                $index->addObjects($records);

                if ($onInsert && is_callable($onInsert)) {
                    call_user_func_array($onInsert, [$recordsAsEntity]);
                }
            }

        });

        if ($safe) {
            for ($i = 0; $i < count($indices); $i++) {
                $modelHelper->algolia->moveIndex($indicesTmp[$i]->indexName, $indices[$i]->indexName);
            }

            $this->_setSettings(false); // To a setSettings to set the slave on the master
        }
    }
728419
public void setSettings(Settings settings) throws IOException {
    synchronized (writer) {
      synchronized (this) {
        if (shutdown) {
          throw new ConnectionShutdownException();
        }
        okHttpSettings.merge(settings);
      }
      writer.settings(settings);
    }
  }
614897
public void setSettings(LinkedHashMap<String, Object> settings) {
        Settings.Builder builder = Settings.settingsBuilder();
        for (Map.Entry<String, Object> entry : settings.entrySet()) {
            builder.put(entry.getKey(), entry.getValue());
        }
        this.settings = builder.build();
    }
1093080
function mergeOptions(defaults, settings) {
  var options = _extends({}, defaults, settings);

  // `Object.assign` do not deeply merge objects, so we
  // have to do it manually for every nested object
  // in options. Although it does not look smart,
  // it's smaller and faster than some fancy
  // merging deep-merge algorithm script.
  if (settings.hasOwnProperty('classes')) {
    options.classes = _extends({}, defaults.classes, settings.classes);

    if (settings.classes.hasOwnProperty('direction')) {
      options.classes.direction = _extends({}, defaults.classes.direction, settings.classes.direction);
    }
  }

  if (settings.hasOwnProperty('breakpoints')) {
    options.breakpoints = _extends({}, defaults.breakpoints, settings.breakpoints);
  }

  return options;
}
1140356
public void setSettings(java.util.Collection<Setting> settings) {
        if (settings == null) {
            this.settings = null;
            return;
        }

        this.settings = new com.amazonaws.internal.SdkInternalList<Setting>(settings);
    }
42831
public function setSettings($settingList = []) {
        if (!$settingList) {
            return;
        }

        if (isset($settingList['persistent'])) {
            $this->setPersistent($settingList['persistent']);
        }

        if (isset($settingList['charset'])) {
            $this->setCharset($settingList['charset']);
        }
    }
349258
public void applySettings() {
        if (determineIfCalledFromSeparateScannerProcess()) {
            return;
        }
        if (!isAnyConsumerBound()) {
            LogManager.d(TAG, "Not synchronizing settings to service, as it has not started up yet");
        } else if (isScannerInDifferentProcess()) {
            LogManager.d(TAG, "Synchronizing settings to service");
            syncSettingsToService();
        } else {
            LogManager.d(TAG, "Not synchronizing settings to service, as it is in the same process");
        }
    }
435455
public static function setMany($settings = [], $defaultSettings = [])
    {
        $settings = static::parseDefaultOptions($settings, $defaultSettings);

        array_walk($settings, function ($value, $key) {
            static::set($key, $value);
        });
    }
1085546
public function setOptions(array $options, $merge = true)
    {
        $this->options = $merge ? ArrayHelper::merge($this->options, $options) : $options;

        return $this;
    }
1029240
private function setSettings($settings)
    {
        if ($settings) {
            foreach ($this->settings as $key => &$value) {
                if (!empty($settings->{$key}) && $settings->{$key}) {
                    $value = $settings->{$key};
                }
            }
        }
    }
99834
public function load(array $config, $merge = true)
    {
        if (true === $merge) {
            $this->internalMerge($config, $this->configsContainer);
        } else {
            $this->configsContainer = $config;
        }
    }
805863
public function setVirtual(array $properties, $merge = false)
    {
        if ($merge === false) {
            $this->_virtual = $properties;

            return $this;
        }

        $properties = array_merge($this->_virtual, $properties);
        $this->_virtual = array_unique($properties);

        return $this;
    }
569046
public void setSettings(java.util.Collection<OutputDestinationSettings> settings) {
        if (settings == null) {
            this.settings = null;
            return;
        }

        this.settings = new java.util.ArrayList<OutputDestinationSettings>(settings);
    }
385151
function(settings) {
		"use strict";

		var parent = this;

		var options = parent.options = mergeRecursive(parent.options, settings);

		// Fatal errors
		// Stop script execution on error
		validateDomainType();
		validateSelector(options.itemSelector, false, "itemSelector");

		if (parent.allowedDataType.indexOf(options.dataType) === -1) {
			throw new Error("The data type '" + options.dataType + "' is not valid data type");
		}

		if (d3.select(options.itemSelector)[0][0] === null) {
			throw new Error("The node '" + options.itemSelector + "' specified in itemSelector does not exists");
		}

		try {
			validateSelector(options.nextSelector, true, "nextSelector");
			validateSelector(options.previousSelector, true, "previousSelector");
		} catch(error) {
			console.log(error.message);
			return false;
		}

		// If other settings contains error, will fallback to default

		if (!settings.hasOwnProperty("subDomain")) {
			this.options.subDomain = getOptimalSubDomain(settings.domain);
		}

		if (typeof options.itemNamespace !== "string" || options.itemNamespace === "") {
			console.log("itemNamespace can not be empty, falling back to cal-heatmap");
			options.itemNamespace = "cal-heatmap";
		}

		// Don't touch these settings
		var s = ["data", "onComplete", "onClick", "afterLoad", "afterLoadData", "afterLoadPreviousDomain", "afterLoadNextDomain"];

		for (var k in s) {
			if (settings.hasOwnProperty(s[k])) {
				options[s[k]] = settings[s[k]];
			}
		}

		options.subDomainDateFormat = (typeof options.subDomainDateFormat === "string" || typeof options.subDomainDateFormat === "function" ? options.subDomainDateFormat : this._domainType[options.subDomain].format.date);
		options.domainLabelFormat = (typeof options.domainLabelFormat === "string" || typeof options.domainLabelFormat === "function" ? options.domainLabelFormat : this._domainType[options.domain].format.legend);
		options.subDomainTextFormat = ((typeof options.subDomainTextFormat === "string" && options.subDomainTextFormat !== "") || typeof options.subDomainTextFormat === "function" ? options.subDomainTextFormat : null);
		options.domainMargin = expandMarginSetting(options.domainMargin);
		options.legendMargin = expandMarginSetting(options.legendMargin);
		options.highlight = parent.expandDateSetting(options.highlight);
		options.itemName = expandItemName(options.itemName);
		options.colLimit = parseColLimit(options.colLimit);
		options.rowLimit = parseRowLimit(options.rowLimit);
		if (!settings.hasOwnProperty("legendMargin")) {
			autoAddLegendMargin();
		}
		autoAlignLabel();

		/**
		 * Validate that a queryString is valid
		 *
		 * @param  {Element|string|bool} selector   The queryString to test
		 * @param  {bool}	canBeFalse	Whether false is an accepted and valid value
		 * @param  {string} name		Name of the tested selector
		 * @throws {Error}				If the selector is not valid
		 * @return {bool}				True if the selector is a valid queryString
		 */
		function validateSelector(selector, canBeFalse, name) {
			if (((canBeFalse && selector === false) || selector instanceof Element || typeof selector === "string") && selector !== "") {
				return true;
			}
			throw new Error("The " + name + " is not valid");
		}

		/**
		 * Return the optimal subDomain for the specified domain
		 *
		 * @param  {string} domain a domain name
		 * @return {string}        the subDomain name
		 */
		function getOptimalSubDomain(domain) {
			switch(domain) {
			case "year":
				return "month";
			case "month":
				return "day";
			case "week":
				return "day";
			case "day":
				return "hour";
			default:
				return "min";
			}
		}

		/**
		 * Ensure that the domain and subdomain are valid
		 *
		 * @throw {Error} when domain or subdomain are not valid
		 * @return {bool} True if domain and subdomain are valid and compatible
		 */
		function validateDomainType() {
			if (!parent._domainType.hasOwnProperty(options.domain) || options.domain === "min" || options.domain.substring(0, 2) === "x_") {
				throw new Error("The domain '" + options.domain + "' is not valid");
			}

			if (!parent._domainType.hasOwnProperty(options.subDomain) || options.subDomain === "year") {
				throw new Error("The subDomain '" + options.subDomain + "' is not valid");
			}

			if (parent._domainType[options.domain].level <= parent._domainType[options.subDomain].level) {
				throw new Error("'" + options.subDomain + "' is not a valid subDomain to '" + options.domain +  "'");
			}

			return true;
		}

		/**
		 * Fine-tune the label alignement depending on its position
		 *
		 * @return void
		 */
		function autoAlignLabel() {
			// Auto-align label, depending on it's position
			if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("align"))) {
				switch(options.label.position) {
				case "left":
					options.label.align = "right";
					break;
				case "right":
					options.label.align = "left";
					break;
				default:
					options.label.align = "center";
				}

				if (options.label.rotate === "left") {
					options.label.align = "right";
				} else if (options.label.rotate === "right") {
					options.label.align = "left";
				}
			}

			if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("offset"))) {
				if (options.label.position === "left" || options.label.position === "right") {
					options.label.offset = {
						x: 10,
						y: 15
					};
				}
			}
		}

		/**
		 * If not specified, add some margin around the legend depending on its position
		 *
		 * @return void
		 */
		function autoAddLegendMargin() {
			switch(options.legendVerticalPosition) {
			case "top":
				options.legendMargin[2] = parent.DEFAULT_LEGEND_MARGIN;
				break;
			case "bottom":
				options.legendMargin[0] = parent.DEFAULT_LEGEND_MARGIN;
				break;
			case "middle":
			case "center":
				options.legendMargin[options.legendHorizontalPosition === "right" ? 3 : 1] = parent.DEFAULT_LEGEND_MARGIN;
			}
		}

		/**
		 * Expand a number of an array of numbers to an usable 4 values array
		 *
		 * @param  {integer|array} value
		 * @return {array}        array
		 */
		function expandMarginSetting(value) {
			if (typeof value === "number") {
				value = [value];
			}

			if (!Array.isArray(value)) {
				console.log("Margin only takes an integer or an array of integers");
				value = [0];
			}

			switch(value.length) {
			case 1:
				return [value[0], value[0], value[0], value[0]];
			case 2:
				return [value[0], value[1], value[0], value[1]];
			case 3:
				return [value[0], value[1], value[2], value[1]];
			case 4:
				return value;
			default:
				return value.slice(0, 4);
			}
		}

		/**
		 * Convert a string to an array like [singular-form, plural-form]
		 *
		 * @param  {string|array} value Date to convert
		 * @return {array}       An array like [singular-form, plural-form]
		 */
		function expandItemName(value) {
			if (typeof value === "string") {
				return [value, value + (value !== "" ? "s" : "")];
			}

			if (Array.isArray(value)) {
				if (value.length === 1) {
					return [value[0], value[0] + "s"];
				} else if (value.length > 2) {
					return value.slice(0, 2);
				}

				return value;
			}

			return ["item", "items"];
		}

		function parseColLimit(value) {
			return value > 0 ? value : null;
		}

		function parseRowLimit(value) {
			if (value > 0 && options.colLimit > 0) {
				console.log("colLimit and rowLimit are mutually exclusive, rowLimit will be ignored");
				return null;
			}
			return value > 0 ? value : null;
		}

		return this._init();

	}
336187
public static function initByRealmObject( StaticRealmDto $realm, array $customSettings = [] )
	{
		self::setSettings([
			self::SET_ENDPOINT => $realm->cdn . "/",
			self::SET_VERSION  => $realm->dd,
		]);

		if (!empty($customSettings))
			self::setSettings($customSettings);

		self::$initialized = true;
	}
407575
public function merge(self $resource, bool $overwrite = true): void
    {
        if ($this->getLocale() !== $resource->getLocale()) {
            trigger_error('Attempting to merge resources of different locale', \E_USER_NOTICE);
        }
        
        $this->addData($resource->data, (bool) $overwrite);
    }
1374865
protected void setReadOnly()
   {
      // try to stop merger in safe way
      if (merger != null)
      {
         merger.dispose();
         merger = null;
      }

      if (flushTask != null)
      {
         flushTask.cancel();
      }
      FLUSH_TIMER.purge();
      this.redoLog = null;
   }