Get instance of this DataStore.

@param Container $container
@param boolean   $forceNew

@return  mixed
974863
public function get($container, $forceNew = false)
    {
        if ($this->shared) {
            if (empty($this->instances) || $forceNew) {
                $this->instances = call_user_func($this->callback, $container);
            }

            return $this->instances;
        }

        return call_user_func($this->callback, $container);
    }
1189638
public function newInstance(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var static $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        // if no id, then it has not been save and can be returned
        if (empty($new->containerId)) {
            return $new;
        }

        $new->containerId = null;

        return $new;
    }
379341
protected function getFactory(): FactoryInterface
    {
        if ($this->container instanceof FactoryInterface) {
            return $this->container;
        }

        return $this->container->get(FactoryInterface::class);
    }
481902
public static function getKernel($forceNewInstance = false)
    {
        if (is_null(self::$_theKernel) || $forceNewInstance) {
            self::$_theKernel = new self();
        }

        return self::$_theKernel;
    }
488772
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
        if (is_null(self::$_clone)) {
            self::$_clone = new AnRegistry();
        }

        if ($config->key) {
            $config->cache_prefix .= '-'.$config->key;
            unset($config->key);
        }

        if (! isset(self::$_instances[$config->cache_prefix])) {

            $instance = clone self::$_clone;
            self::$_instances[$config->cache_prefix] = $instance;

            $instance->setCachePrefix($config->cache_prefix);
            $instance->enableCache($config->cache_enabled);
        }

        return self::$_instances[$config->cache_prefix];
    }
404185
public function getContainer()
    {
        if (null !== $this->container) {
            throw new ContainerAlreadyExistsException($this->container);
        }

        // Construct container
        $this->container = new Container();
        $this->hydrateContainerWithBootstrapParameters();

        if (false === $this->tryParseContainerDump()) {
            $this->hydrateContainerWithApplicationParameters();
            $this->loadApplicationServices();
        }

        return $this->container;
    }
1297457
protected function getContainerBuilder(): ContainerBuilder
    {
        $container = new ContainerBuilder();
        $container->getParameterBag()->add($this->getKernelParameters());

        if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) {
            $container->setProxyInstantiator(new RuntimeInstantiator());
        }

        return $container;
    }
1085315
public static function getInstance($config=[],$force=false){
      if (is_null( self::$instance) || $force===true){
        self::$instance=new self($config);
      }

      return self::$instance;
    }
1312360
final public function getClass($docType = '', $forceNew = false) {
        if (!isset($this->annotations['class']) || $forceNew)
            $this->annotations['class'] = $this->parseDocComment($this->reflector->getDocComment(), $docType);

        return ($this->annotations['class']) ? $this->annotations['class'] : array();
    }
205004
public static function getFormToken($forceNew = false)
	{
		$hash = \App::hash(\User::get('id', 0) . \App::get('session')->getToken($forceNew));

		return $hash;
	}
819749
public static function instance($newInstance = null)
    {
        static $instance;

        if ($newInstance instanceof self) {
            $instance = $newInstance;
        }

        if (!($instance instanceof self)) {
            $instance = new self();
        }

        return $instance;
    }
405325
public function get(ContainerInterface $container = null)
    {
        if (empty($this->arguments)) {
            $instance = new $this->class();
        } else {
            $ref = new \ReflectionClass($this->class);
            $instance = $ref->newInstanceArgs($this->prepare($container, $this->arguments));
        }

        return $this->executeMethods($instance, $container);
    }
757569
public static function getInstance(AnConfigInterface $config, AnServiceInterface $container)
    {
        if (!$container->has($config->service_identifier)) {
            $instance = new AnMail($config);
            $container->set($config->service_identifier, $instance);
        }

        return $container->get($config->service_identifier);
    }
794992
protected function makeNewContainer()
    {
        $container = new Container();
        $container->classSet($this->entityClass);
        $container->setPropertyMapper( PropertyMapperEntityData::class );
        return $container;
    }
1154437
public function pathResolvable(Container $container)
    {
        $event = $this->loadEventFromPath($container);
        return ($event instanceof EventInterface) && $event->id();
    }
1081837
protected function getRealContainer()/*# : ContainerInterface */
    {
        $cont = $this->getContainer();

        // get delegator recursively
        if ($cont instanceof DelegatorAwareInterface &&
            $cont->hasDelegator()
        ) {
            $cont = $cont->getDelegator(true);
        }

        return $cont;
    }
1270534
public static function ActiveStore($ForceMethod = NULL) {
      // Get the active cache name
      $ActiveCache = self::ActiveCache();
      if (!is_null($ForceMethod))
         $ActiveCache = $ForceMethod;
      $ActiveCache = ucfirst($ActiveCache);
      
      // Overrides
      if (defined('CACHE_STORE_OVERRIDE') && defined('CACHE_METHOD_OVERRIDE') && CACHE_METHOD_OVERRIDE == $ActiveCache)
         return unserialize(CACHE_STORE_OVERRIDE);
      
      $apc = false;
      if (C('Garden.Apc', false) && C('Garden.Cache.ApcPrecache', false) && function_exists('apc_fetch'))
         $apc = true;
      
      $LocalStore = null;
      $ActiveStore = null;
      $ActiveStoreKey = "Cache.{$ActiveCache}.Store";
      
      // Check memory
      if (is_null($LocalStore)) {
         if (array_key_exists($ActiveCache, Gdn_Cache::$Stores)) {
            $LocalStore = Gdn_Cache::$Stores[$ActiveCache];
         }
      }
      
      // Check APC cache
      if (is_null($LocalStore) && $apc) {
         $LocalStore = apc_fetch($ActiveStoreKey);
         if ($LocalStore) {
            Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;
         }
      }
      
      if (is_array($LocalStore)) {
         
         // Convert to ActiveStore format (with 'Active' key)
         $Save = false;
         $ActiveStore = array();
         foreach ($LocalStore as $StoreServerName => &$StoreServer) {
            $IsDelayed = &$StoreServer['Delay'];
            $IsActive = &$StoreServer['Active'];
            
            if (is_numeric($IsDelayed)) {
               if ($IsDelayed < time()) {
                  $IsActive = true;
                  $IsDelayed = false;
                  $StoreServer['Fails'] = 0;
                  $Save = true;
               } else {
                  if ($IsActive) {
                     $IsActive = false;
                     $Save = true;
                  }
               }
            }

            // Add active servers to ActiveStore array
            if ($IsActive)
               $ActiveStore[] = $StoreServer['Server'];
         }
         
      }

      // No local copy, get from config
      if (is_null($ActiveStore)) {
         $ActiveStore = C($ActiveStoreKey, false);

         // Convert to LocalStore format
         $LocalStore = array();
         $ActiveStore = (array)$ActiveStore;
         foreach ($ActiveStore as $StoreServer) {
            $StoreServerName = md5($StoreServer);
            $LocalStore[$StoreServerName] = array(
               'Server' => $StoreServer,
               'Active' => true,
               'Delay'  => false,
               'Fails'  => 0
            );
         }
         
         $Save = true;
      }
      
      if ($Save) {
         // Save to memory
         Gdn_Cache::$Stores[$ActiveCache] = $LocalStore;

         // Save back to APC for later
         if ($apc) {
            apc_store($ActiveStoreKey, $LocalStore, Gdn_Cache::APC_CACHE_DURATION);
         }
      }
      
      return $ActiveStore;
   }