Gets the current kernel instance.

@param bool $forceNewInstance Boolean value indicating if a new instance
should be obtained even if a previous one exists

@return RuntimeKernel
481902
public static function getKernel($forceNewInstance = false)
    {
        if (is_null(self::$_theKernel) || $forceNewInstance) {
            self::$_theKernel = new self();
        }

        return self::$_theKernel;
    }
563842
public static function getInstance($name, $args = [], $forceNew = false)
    {
        $key = strtolower($name);

        $called = get_called_class();

        if (empty(static::$instances[$called][$key]) || $forceNew) {
            static::$instances[$called][$key] = static::create($name, ...$args);
        }

        return static::$instances[$called][$key];
    }
4288
public static function getInstance()
    {
        $fileManager    = new FileManager();
        $serviceManager = ZendFramework2Environnement::getDependence($fileManager);
        $entityManager  = $serviceManager->get('doctrine.entitymanager.orm_default');

        if (($entityManager instanceof EntityManager) === false) {
            throw new \Exception(
                sprintf(
                    'Service manager return instanceof "%s" instead of "%s"',
                    is_object($entityManager) === true ? get_class($entityManager) : gettype($entityManager),
                    'Doctrine\ORM\EntityManager'
                )
            );
        }

        return new Doctrine2MetaDataDAO($entityManager);
    }
862250
private function getAnnotations($forceNew = false) {
        if ($this->annotations === null || $forceNew === true) {
            $this->annotations = new Annotation(get_called_class());
        }

        return $this->annotations;
    }
454164
public function getToken($forceRefresh = false)
    {
        $cached = $this->getCache()->fetch($this->getCacheKey()) ?: $this->token;

        if ($forceRefresh || empty($cached)) {

            $result = $this->getTokenFromServer();

            $this->checkTokenResponse($result);

            $this->setToken(
                $token = $result[$this->tokenJsonKey],
                $this->expiresJsonKey ? $result[$this->expiresJsonKey] : null
            );

            return $token;
        }

        return $cached;
    }
1178142
public function getFormToken($forceNew = false) {
	   
        return md5($this->get('secret') . $this->getSession()->getToken($forceNew));    
    }
1197832
static function getInstance($databaseNameOrResource = '*LOCAL', $userOrI5NamingFlag = '', $password = '', $extensionPrefix = '', $isPersistent = false, $forceNew = false)
    {
        // if we're forcing a new instance, close db conn first if exists.
        if ($forceNew && self::hasInstance() && isset(self::$instance->conn))
        {
            self::$instance->disconnect();
        }

        // if we're forcing a new instance, or an instance hasn't been created yet, create one
        if ($forceNew || self::$instance == NULL) {
            $toolkitService = __CLASS__;
            self::$instance = new $toolkitService($databaseNameOrResource, $userOrI5NamingFlag, $password, $extensionPrefix, $isPersistent);
        }

        if (self::$instance) {
            // instance exists
            return self::$instance;
        } else {
            // some problem
            return false;
        }
    }
1177258
public function getCookie($forceRefresh = false)
    {
        $cacheKey = $this->cachePrefix . $this->stu_id;
        $cached = $this->getCache()->fetch($cacheKey);
        if ($forceRefresh || empty($cached)) {
            $jar = $this->login();
            //Cache the cookieJar 3000 s.
            $this->getCache()->save($cacheKey, serialize($jar), 3000);
            return $jar;
        }
        return unserialize($cached);
    }
1085315
public static function getInstance($config=[],$force=false){
      if (is_null( self::$instance) || $force===true){
        self::$instance=new self($config);
      }

      return self::$instance;
    }
307732
public static function instance($forcereload = false) {
        global $CFG;
        if ($forcereload || self::$instance === null) {
            // Initialise a new factory to facilitate our needs.
            if (defined('CACHE_DISABLE_ALL') && CACHE_DISABLE_ALL !== false) {
                // The cache has been disabled. Load disabledlib and start using the factory designed to handle this
                // situation. It will use disabled alternatives where available.
                require_once($CFG->dirroot.'/cache/disabledlib.php');
                self::$instance = new cache_factory_disabled();
            } else if ((defined('PHPUNIT_TEST') && PHPUNIT_TEST) || defined('BEHAT_SITE_RUNNING')) {
                // We're using the test factory.
                require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php');
                self::$instance = new cache_phpunit_factory();
                if (defined('CACHE_DISABLE_STORES') && CACHE_DISABLE_STORES !== false) {
                    // The cache stores have been disabled.
                    self::$instance->set_state(self::STATE_STORES_DISABLED);
                }
            } else {
                // We're using the regular factory.
                self::$instance = new cache_factory();
                if (defined('CACHE_DISABLE_STORES') && CACHE_DISABLE_STORES !== false) {
                    // The cache stores have been disabled.
                    self::$instance->set_state(self::STATE_STORES_DISABLED);
                }
            }
        }
        return self::$instance;
    }
761955
private function getToken(Client $client, $forceNew = false)
    {
        $tokenName = sprintf('keystone_token_%s', rawurlencode($client->getTokenUrl()));

        // see if token is in cache
        if (!$forceNew && $cachedToken = $this->cache->get($tokenName)) {
            $token = unserialize($cachedToken);
        }

        if (!isset($token) || !($token instanceof Token) || $this->tokenIsExpired($token)) {
            $token = $this->createToken($client);
            $this->cache->set($tokenName, serialize($token), $token->getExpirationDate()->getTimestamp() - time());
        }

        return $token;
    }
1006056
public Object createNewInstance() throws BlueprintTemplateException {
		if ( this.getNewInstance() != null ) {
            // XXX: warn if the return of the callback is not the same class as the target?
			return this.getNewInstance().createInstance();
		} else {
			return this.getTemplate().construct( this.getTarget() );
		}
	}
109975
public static function getInstance()
    {
        if (true === is_null(self::$_instance)) {
            self::$_instance = new self();
            self::$_instance->variables = [];
            self::$_instance->system_errors = [];
            self::$_instance->system_debug = [];
            self::$_instance->variables["config"] = [];
        }

        return self::$_instance;
    }
42351
public function getInstantWinOccurrenceMapper()
    {
        if (null === $this->instantWinOccurrenceMapper) {
            $this->instantWinOccurrenceMapper = $this->serviceLocator->get(
                'playgroundgame_instantwinoccurrence_mapper'
            );
        }

        return $this->instantWinOccurrenceMapper;
    }
898115
public function getRepository($name = null, $source = null, $forceNew = false)
    {
        $name = $name ?: $this->getName();

        $key = ModelResolver::getDIKey($name);

        // Let's prepare controller getter.
        if (!$this->container->exists($key)) {
            // Use resolver to find model class and create it.
            $this->container->share($key, function (Container $container) use ($name, $source) {
                $config    = clone $this->config;
                $modelName = ucfirst($name) . 'Model';
                $repoName  = ucfirst($name) . 'Repository';
                $source    = $source ?: $this->getDataSource();

                /*
                 * If the name of this model not same as this controller, we don't pass name into it,
                 * so that the model will keep it's own name.
                 * Otherwise we override the name in model config with ours.
                 */
                if ($name && strcasecmp($name, $this->getName()) !== 0) {
                    $config['name'] = null;
                }

                try {
                    $repoResolver = $this->getPackage()->getMvcResolver()->getRepositoryResolver();

                    // Use RepositoryResolver to fin Repository class
                    try {
                        $class = $repoResolver->resolve($repoName);
                    } catch (\DomainException $e) {
                        // Use ModelResolver to get legacy Model classes
                        // @deprecated
                        $class = $repoResolver->getModelResolver()->resolve($modelName);
                    }

                    // Create object by container, container will auto inject all necessary dependencies
                    return $container->createSharedObject($class, ['config' => $config]);
                } catch (\Exception $e) {
                    if (!$e instanceof \DomainException && !$e instanceof \UnexpectedValueException) {
                        throw $e;
                    }

                    // Guess the repository position
                    $class = MvcHelper::getPackageNamespace($this) . '\Repository\\' . ucfirst($repoName);

                    if (class_exists($class)) {
                        return $container->createSharedObject($class, ['source' => $source, 'config' => $config]);
                    }

                    // Guess the model position
                    // @deprecated
                    $class = MvcHelper::getPackageNamespace($this) . '\Model\\' . ucfirst($modelName);

                    if (class_exists($class)) {
                        return $container->createSharedObject($class, ['source' => $source, 'config' => $config]);
                    }

                    $config['name'] = $name;

                    return new Repository($config);
                }
            });
        }

        // Get model from controller.
        return $this->container->get($key, $forceNew);
    }
1207668
public static function getKernel()
    {
        if (!isset(self::$_instance)) {
            if ($cls = Kwf_Config::getValue('symfony.kernelClass')) {
                if (!class_exists('Symfony\Component\HttpKernel\Kernel')) return null;

                self::$_instance = new $cls();
                self::$_instance->boot(); //make sure it is booted (won't do it twice)
            } else {
                return null;
            }
        }
        return self::$_instance;
    }
739487
private static function getInstance()
    {
        if (self::$_instance == null) {
            self::$_instance = new Fabricate();
            self::$_instance->config = new FabricateConfig();
            self::$_instance->registry = new FabricateRegistry('Fabricate', null);
            self::$_instance->traits = [];
        }
        return self::$_instance;
    }