Save the tour and it's configuration to the database.

@param   boolean     $force      Whether to force writing to the database.
@return  $this
426585
public function persist($force = false) {
        global $DB;

        if (!$this->dirty && !$force) {
            return $this;
        }

        if ($this->id) {
            $record = $this->to_record();
            $DB->update_record('tool_usertours_tours', $record);
        } else {
            $this->calculate_sortorder();
            $record = $this->to_record();
            unset($record->id);
            $this->id = $DB->insert_record('tool_usertours_tours', $record);
        }

        $this->reload();

        // Notify the cache that a tour has changed.
        cache::notify_tour_change();

        return $this;
    }
1335357
public function ensurePropertiesAttributes($force = false)
    {
        if ($this->propertiesAttributes === null || $force === true) {
            $this->ensurePropertiesIds($force);
            $this->propertiesAttributes = [];

            foreach ($this->propertiesIds as $propertyId) {
                $this->propertiesAttributes[$propertyId] = Property::propertyKeyForId($propertyId);
            }
        }
    }
1090281
public function hasCache($force = FALSE) {

		if(!isset($this->cacheFound) || $force) {
			$this->cacheFound = is_dir($this->path . self::CACHE_PATH);
		}

		return $this->cacheFound;

	}
1206477
protected function resetLang($force = false)
    {
        if ($this->autoResetLang || $force) {
            $this->lang = null;
        }

        return $this;
    }
938179
public function fill(array $input, bool $force = false)
    {
        foreach ($input as $key => $value) {
            if ($force) {
                $this->setAttribute($key, $value);

                continue;
            }

            if ((empty($this->fillable) || in_array($key, $this->fillable)) && !in_array($key, $this->guarded)) {
                $this->setAttribute($key, $value);
            }
        }
    }
1248174
public function validateSecret(bool $force = false): self
    {
        // If we're running from CLI, secret isn't necessary.
        if ($force || 'cli' !== PHP_SAPI) {
            $secret     = $this->params->getBotParam('secret');
            $secret_get = $this->params->getScriptParam('s');
            if (!isset($secret, $secret_get) || $secret !== $secret_get) {
                throw new InvalidAccessException('Invalid access');
            }
        }

        return $this;
    }
471293
public function get_definition($force = false) {
        if ($this->definition === false || $force) {
            $this->load_definition();
        }
        return $this->definition;
    }
729792
public function initConfig($force = false) {
		$pluginName = $this->_getPluginName();
		$checkPath = $this->_getCheckPath();
		$configFile = $this->_getConfigFile();
		$language = (string)Configure::read('Config.language');
		if (!$force && !empty($checkPath) && Configure::check($checkPath)) {
			return;
		}

		// Local config without extra config file
		$conf = $this->getConfig();

		$cachePath = 'static_cfg_' . Inflector::underscore($pluginName) . '_' . $language;
		$cached = Cache::read($cachePath, CAKE_CONFIG_PLUGIN_CACHE_CFG);
		if ($cached !== false) {
			$conf = Hash::mergeDiff($conf, (array)$cached);
			Configure::write($pluginName, $conf);

			return;
		}
		Configure::config('phpcfg', new PhpReader($this->path));
		// Fallback to Plugin config which can be overwritten via local app config.
		Configure::load($pluginName . '.' . $configFile, 'phpcfg', false);
		$defaultConf = $this->getConfig();

		// Local app config
		if (file_exists($this->path . $configFile . '.php')) {
			Configure::load($configFile, 'phpcfg', false);
			$localConf = $this->getConfig();
			$conf = Hash::mergeDiff($conf, $localConf);
		}
		Configure::drop('phpcfg');
		// BC comp:
		$conf = Hash::mergeDiff($conf, $defaultConf);
		Cache::write($cachePath, $conf, CAKE_CONFIG_PLUGIN_CACHE_CFG);
		Configure::write($pluginName, $conf);
	}
933550
public function compile($force = false)
    {
        $this->commandCaller->compile($this->configFile, $force, $this->target);
    }
641173
public function store(string $name = '', $force = false): Driver
    {
        if ('' !== $name && 'complex' == $this->config['type']) {
            return $this->connect($this->config[$name], $force);
        }

        return $this->init();
    }
840368
public function toggleClass(string $class, ?bool $force = null): self
    {
        $this->classList->toggle($class, $force);

        return $this;
    }
122187
public function findAllToRefreshToken(bool $force = false)
    {
        $query = $this->newQuery();

        return $force ? $query->get() : $query->whereNull('token')->get();
    }
250213
public function open($filename, $force = false)
    {
        if (!$this->filesystem->exists($filename) && $force) {
            return $this->filesystem->create($filename);
        }

        return $this->filesystem->open($filename);
    }
430411
public function delete(string $id, bool $force = false)
    {
        return $this->curl->delete($this->url.'/'.$id.'?'.http_build_query(['force' => $force]));
    }
15671
public function get($force = false)
    {
        // Check if current set
        if (is_null(self::$current) || $force) {
            // Get environment variable (if set and valid)
            $releaseStage = trim(getenv('RELEASE_STAGE'));
            $releaseStage = in_array($releaseStage, $this->getAll()) ? $releaseStage : null;

            // If environment variable not set/valid, try to detect environment by url or path
            $releaseStage = $releaseStage ?: $this->determineFromPath();

            $releaseStage = $releaseStage ?: $this->detectAppServer();

            // If environment variable still not set, assume we are in production!
            $releaseStage = $releaseStage ?: self::PRODUCTION;

            self::$current = $releaseStage;
        }

        return self::$current;
    }
646169
public function get($force = false)
    {
        if (is_null($this->settings) || $force) {
            $_settings = $this->db->select()
                ->from($this->getTable())
                ->get();
            $settings = array();
            foreach ($_settings as $setting) {
                // decrypt the value if needed
                if (in_array($setting['setting_key'], $this->getEncrypted()) && ! empty($setting['setting_value'])) {
                    $settings[$setting['setting_key']] = $setting['setting_value'] = $this->getEncrypt()->decode($setting['setting_value']);
                }
                
                // unserialize the value
                if (in_array($setting['setting_key'], $this->getSerialized()) && ! empty($setting['setting_value'])) {
                    $settings[$setting['setting_key']] = $setting['setting_value'] = unserialize($setting['setting_value']);
                    foreach ($settings[$setting['setting_key']] as $key => $value) {
                        if ($value == '') {
                            unset($settings[$setting['setting_key']][$key]); // remove blank entries
                        }
                    }
                }
                
                // sort out new line values
                if (in_array($setting['setting_key'], $this->getNewLines())) {
                    $settings[$setting['setting_key']] = $setting['setting_value'] = explode("\n", $setting['setting_value']);
                    foreach ($settings[$setting['setting_key']] as $key => $value) {
                        $value = trim($value);
                        if ($value == '') {
                            unset($settings[$setting['setting_key']][$key]); // remove blank entries
                        } else {
                            $settings[$setting['setting_key']][$key] = $value;
                        }
                    }
                }
                
                $settings[$setting['setting_key']] = $setting['setting_value'];
            }
            
            $ignore = array(
                'license_check',
                'license_status'
            );
            foreach ($this->getDefaults() as $key => $value) {
                // setup the override check
                if (isset($this->overrides[$key]) && ! in_array($key, $ignore)) {
                    $settings[$key] = $this->overrides[$key];
                }
                
                if (! isset($settings[$key])) {
                    $settings[$key] = $value;
                }
            }
            
            $this->settings = $settings;
            
            if($this->settings['api_key'] == '')
            {
                $this->settings['api_key'] = $this->getEncrypt()->guid();
            }
            
            if($this->settings['api_secret'] == '')
            {
                $this->settings['api_secret'] = $this->getEncrypt()->guid();
            }            
        }
        
        return $this->settings;
    }
25239
public function delete($force = false)
    {
        $this->getParent()->channelDelete($this->getId(), $force);

        unset($this);
    }