Get release stage

@param boolean $force Bypass any possible caching

@return string textual representation of the current release stage
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;
    }
337838
private function getEntityManager($force = false)
    {
        /** @var EntityManager $em */
        $em = $this->doctrine->getManagerForClass($this->entityClass);
        if ($force) {
            if (!$em->isOpen()) {
                $this->resetEntityManager();
                $em = $this->doctrine->getManagerForClass($this->entityClass);
            } else {
                /**
                 * ensure that the transaction is fully rolled back
                 * in case if a nested transaction is rolled back but the entity manager is not closed
                 * this may happen if the EntityManager::rollback() method is called
                 * without the call of EntityManager::close() method
                 * @link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html#exception-handling
                 */
                $connection = $em->getConnection();
                if ($connection->getTransactionNestingLevel() > 0 && $connection->isRollbackOnly()) {
                    while ($connection->getTransactionNestingLevel() > 0) {
                        $connection->rollBack();
                    }
                }
            }
        }

        return $em;
    }
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;
    }
265049
public function getStaticContents($force = false) : CNabuSiteStaticContentList
    {
        if (!$this->isBuiltIn() &&
            ($this->nb_site_static_content_list->isEmpty() || $force)
        ) {
            $this->nb_site_static_content_list = CNabuSiteStaticContent::getStaticContentsForSite($this);
            $this->nb_site_static_content_list->sort();
        }

        return $this->nb_site_static_content_list;
    }
1108671
public function drop($force = false)
    {
        $this->clearCache();
        
        $this->force = $force;

        return 'DROP TABLE ' . ($this->isForce() ? 'IF EXISTS ' : '') . '`' . $this->getCurrentTable()->getFullTableName() . '`;';
    }
951425
public function get_talkID( $force = false ) {

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

		$tArray = array(
			'action' => 'query',
			'prop'   => 'info',
			'inprop' => 'talkid',
			'titles' => $this->title,
		);

		pecho( "Getting talk page ID for {$this->title}..\n\n", PECHO_NORMAL );

		$tRes = $this->wiki->apiQuery( $tArray );

		if( isset( $tRes['query']['pages'][$this->pageid]['talkid'] ) ) {
			$this->talkid = $tRes['query']['pages'][$this->pageid]['talkid'];
		} else $this->talkid = null;

		return $this->talkid;
	}
749893
public function read($force = false)
	{
		// initialize the session
		$this->data = array();
		$this->keys = array();
		$this->flash = array();

		// get the session cookie
		$cookie = $this->_get_cookie();

		// if a cookie was present, find the session record
		if ($cookie and ! $force and isset($cookie[0]))
		{
			// read the session file
			$payload = $this->_read_redis($cookie[0]);

			if ($payload === false)
			{
				// cookie present, but session record missing. force creation of a new session
				return $this->read(true);
			}

			// unpack the payload
			$payload = $this->_unserialize($payload);

			// session referral?
			if (isset($payload['rotated_session_id']))
			{
				$payload = $this->_read_redis($payload['rotated_session_id']);
				if ($payload === false)
				{
					// cookie present, but session record missing. force creation of a new session
					return $this->read(true);
				}

				// unpack the payload
				$payload = $this->_unserialize($payload);
			}

			if ( ! isset($payload[0]) or ! is_array($payload[0]))
			{
				logger('DEBUG', 'Error: not a valid redis session payload!');
			}
			elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp())
			{
				logger('DEBUG', 'Error: session id has expired!');
			}
			elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip().\Input::real_ip()))
			{
				logger('DEBUG', 'Error: IP address in the session doesn\'t match this requests source IP!');
			}
			elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent())
			{
				logger('DEBUG', 'Error: User agent in the session doesn\'t match the browsers user agent string!');
			}
			else
			{
				// session is valid, retrieve the rest of the payload
				if (isset($payload[0]) and is_array($payload[0])) $this->keys  = $payload[0];
				if (isset($payload[1]) and is_array($payload[1])) $this->data  = $payload[1];
				if (isset($payload[2]) and is_array($payload[2])) $this->flash = $payload[2];
			}
		}

		return parent::read();
	}
712012
public function refresh($force = false) {
		if (!$force && time() - $this->last_fetch < $this->config['refresh_interval']) {
			return;
		}
		$clis = [];
		foreach ($this->conf['namespace'] as $v) {
			$clis[] = $this->getClient($v);
		}
		foreach ($clis as $cli) {
			$cli->recv();
			if ($cli->statusCode === 304) {
				continue;
			}
			$res = json_decode($cli->body, true);
			$ns = $res['namespaceName'];
			$this->last_key[$ns] = $res['releaseKey'];
			$this->update($ns, $res['configurations']);
		}
		$this->last_fetch = time();
	}
338974
private function fopen($force = false) {
            if ($force || !$this->fp) {
                $this->fclose();
                $this->fp = is_resource($this->config->savePath) ? $this->config->savePath
                    : fopen($this->config->savePath, 'ab');
            }

            return $this;
        }
901201
public function getTemplateConnections(bool $force = false) : CNabuMessagingServiceTemplateList
    {
        if ($this->nb_messaging_template_service_list->isEmpty() || $force) {
            $this->nb_messaging_template_service_list->clear();
            $this->nb_messaging_template_service_list->merge(
                CNabuMessagingServiceTemplate::getTemplatesForService($this)
            );
        }

        return $this->nb_messaging_template_service_list;
    }
509076
public function flushCacheState(bool $force = false): void
    {
        if ((!empty($this->newCacheState) && is_writable($this->cacheDir)) || $force) {
            $fullCacheMap = $this->newCacheState + $this->cacheState;
            $cachePath    = substr(var_export($this->cacheDir, true), 1, -1);
            $rootPath     = substr(var_export($this->appDir, true), 1, -1);
            $cacheData    = '<?php return ' . var_export($fullCacheMap, true) . ';';
            $cacheData    = strtr($cacheData, [
                '\'' . $cachePath => 'AOP_CACHE_DIR . \'',
                '\'' . $rootPath  => 'AOP_ROOT_DIR . \''
            ]);
            $fullCacheFileName = $this->cacheDir . self::CACHE_FILE_NAME;
            file_put_contents($fullCacheFileName, $cacheData, LOCK_EX);
            // For cache files we don't want executable bits by default
            chmod($fullCacheFileName, $this->fileMode & (~0111));

            if (function_exists('opcache_invalidate')) {
                opcache_invalidate($fullCacheFileName, true);
            }
            $this->cacheState    = $this->newCacheState + $this->cacheState;
            $this->newCacheState = [];
        }
    }
422415
public function isWebImage($force = false) {

		if(!isset($this->mimetype) || $force) {
			$this->mimetype = MimeTypeGetter::get($this->folder->getPath() . $this->filename);
		}
		return preg_match('~^image/(p?jpeg|png|gif)$~', $this->mimetype);

	}
650213
public function getRolesPermissions($force = false)
    {
        if (empty($this->cachedRolePermissions) or $force) {
            $this->cachedRolePermissions = $this->getFreshRolesPermissions();
        }

        return $this->cachedRolePermissions;
    }
82410
public function relationGetSessionKey($force = false)
    {
        if ($this->sessionKey && !$force) {
            return $this->sessionKey;
        }

        if (post('_relation_session_key')) {
            return $this->sessionKey = post('_relation_session_key');
        }

        if (post('_session_key')) {
            return $this->sessionKey = post('_session_key');
        }

        return $this->sessionKey = FormHelper::getSessionKey();
    }
345406
public function getItems($force = false)
    {
        if ($this->nb_catalog_item_tree->isEmpty() || $force) {
            $this->nb_catalog_item_tree->populate();
        }

        return $this->nb_catalog_item_tree;
    }
121931
public function getLowFF(bool $force = false): int
    {
        if ($force || $this->isOver32()) {
            return 0xFFFFFFFF;
        }
        return $this->getLow32();
    }
689553
public function getActiveServices(bool $force = false) : CNabuMessagingServiceList
    {
        if ($this->nb_messaging_service_list->isEmpty() || $force) {
            $this->nb_messaging_service_list->clear();
            if (($nb_messaging = $this->getMessaging()) instanceof CNabuMessaging &&
                !($nb_services_list = $nb_messaging->getActiveServices())->isEmpty()
            ) {
                $nb_services_list->iterate(function($key, CNabuMessagingService $nb_service) {
                    if ($nb_service->isTemplateConnected($this->getId())) {
                        $this->nb_messaging_service_list->addItem($nb_service);
                    }
                    return true;
                });
            }
        }

        return $this->nb_messaging_service_list;
    }