Returns module instance by its name

@param object $name
@return \Krystal\Application\Module\AbstractModule
195211
public function getModule($name)
    {
        if ($this->isLoaded($name)) {
            return $this->loaded[$name];
        } else {
            return $this->loadModuleByName($name);
        }
    }
16412
static function getInstance($name = null)
  {
    if (empty($name)) {
      $name = get_called_class();
    }
    if (!empty(static::$plugins[$name])) {
      return static::$plugins[$name];
    }
    return false;
  }
899689
public static function getInstance(string $name = 'default'): self
    {
        if (!isset(self::$instances[$name])) {
            self::setInstance($name, new self());
        }

        return self::$instances[$name];
    }
955661
protected static function resolveFacadeInstance($name)
    {
        if (is_object($name)) return $name;

        if (isset(static::$resolvedInstance[$name])) {
            return static::$resolvedInstance[$name];
        }

        return static::$resolvedInstance[$name] = static::$app[$name];
    }
645484
public function quessByName(string $name)
    {
        return $this->first(function(ExtensionContract $extension) use($name) {
            $package = $extension->getPackageName();

            return (str_contains($package, 'module-')) ? $package === 'module-' . $name : $package === 'component-' . $name;
        });
    }
371048
public static function loadModule($moduleName) {
        $moduleConf = self::getModuleConf($moduleName);

        try {

            if (isset($moduleConf['requires_php_extension']) && is_array($moduleConf['requires_php_extension'])) {
                self::checkPhpExtensions($moduleConf['requires_php_extension']);
            }

            $tmpModule = new \ReflectionClass('\\pff\\modules\\' . $moduleConf['class']);
            if ($tmpModule->isSubclassOf('\\pff\\Abs\\AModule')) {
                $moduleName = strtolower($moduleConf['name']);

                if (isset(self::$_modules[$moduleName])) { //Module has already been loaded
                    return self::$_modules[$moduleName];
                }

                self::$_modules[$moduleName] = $tmpModule->newInstance();
                self::$_modules[$moduleName]->setModuleName($moduleConf['name']);
                self::$_modules[$moduleName]->setModuleVersion($moduleConf['version']);
                self::$_modules[$moduleName]->setModuleDescription($moduleConf['desc']);
                self::$_modules[$moduleName]->setConfig(ServiceContainer::get('config'));
                self::$_modules[$moduleName]->setApp(ServiceContainer::get('app'));
                (isset($moduleConf['runBefore']))? $moduleLoadBefore = $moduleConf['runBefore']: $moduleLoadBefore = null ;

                if (isset ($moduleConf['requires']) && is_array($moduleConf['requires'])) {
                    self::$_modules[$moduleName]->setModuleRequirements($moduleConf['requires']);
                    foreach ($moduleConf['requires'] as $requiredModuleName) {
                        self::loadModule($requiredModuleName);
                        self::$_modules[$moduleName]->registerRequiredModule(self::$_modules[$requiredModuleName]);
                    }
                }

                if ($tmpModule->isSubclassOf('\pff\Iface\IHookProvider')) {
                    ServiceContainer::get('hookmanager')->registerHook(self::$_modules[$moduleName], $moduleName, $moduleLoadBefore);
                }

                return self::$_modules[$moduleName];

            } else {
                throw new ModuleException("Invalid module: " . $moduleConf['name']);
            }
        }
        catch (\ReflectionException $e) {
            throw new ModuleException("Unable to create module instance: " . $e->getMessage());
        }

    }
858975
protected static function resolveFacadeInstance($name)
    {
        if (is_object($name)) {
            return $name;
        }

        if (isset(static::$resolvedInstance[$name])) {
            return static::$resolvedInstance[$name];
        }

        return static::$resolvedInstance[$name] = Zilf::$container->getShare($name);
    }
504998
public function getModule($name)
	{
	    $name = $this->parseModuleAlias($name);
	    $uid = 'module.' . $name;
	    
	    if ($this->hasModule($name)) {
		    /* @var $module Module */
	        return $this->get($uid);
		} else {
		    $basePath = rtrim($this->basePath, '\\/' ) . '/' . $name;
		    if (file_exists($basePath)) {
		        
		        $this->setModule($name, $basePath);
		        
		        return $this->get($uid);;
		    }
		}
		
		return null;
	}
356122
public static function getInstance($name)
    {
        if (is_null(self::$instance)) {
            $arr = explode('.', $name);
            $company = $arr[0];
            $type = $arr[1];
            $className = self::$map[$company][$type];
            self::$instance = new $className;
        }

        return self::$instance;
    }
1061646
public function get($name)
    {
        if (! $this->has($name)) return null;

        $def = $this->components[$name];

        // already initialized.
        if (! $def instanceof ComponentDefine) {
            return $def;
        }

        // initialize.
        return $def->getInstance();
    }
1195952
public function &load(string $name) : ModularAbstract
    {
        $modular =& $this->internalGetModular($name);
        if (!$this->hasLoaded($name)) {
            $modular->init();
            $this->loadedModular[$this->sanitizeModularName($name)] = true;
        }

        return $modular;
    }
287952
public static function instance($name = null)
	{
		if ($name !== null)
		{
			if ( ! array_key_exists($name, static::$_instances))
			{
				return false;
			}

			return static::$_instances[$name];
		}

		if (static::$_instance === null)
		{
			static::$_instance = static::forge();
		}

		return static::$_instance;
	}
731371
protected function getPluginClassByName($name)
    {
        if (array_key_exists($name, $this->plugins) === false) {
            return false;
        }

        return $this->plugins[$name];
    }
245352
protected static function resolveFacadeInstance($name)
		{
			if (is_object($name)) {
				return $name;
			}

			if (isset(static::$resolvedInstance[$name])) {
				return static::$resolvedInstance[$name];
			}

			return false;
		}
703052
public static function getModulePath($name): string
    {
        $modulePath = static::$modulePath;
        return str_replace(DS . DS, DS, $modulePath . DS . $name . DS);
    }
724894
public function getInstanceDescriptor($name) {
		if (isset($this->instanceDescriptors[$name])) {
			return $this->instanceDescriptors[$name];
		} elseif (isset($this->declaredInstances[$name])) {
			$this->instanceDescriptors[$name] = new MoufInstanceDescriptor($this, $name);
			return $this->instanceDescriptors[$name];
		} else {
			throw new MoufContainerException("Instance '".$name."' does not exist.");
		}
	}
1175297
public static function getInstance($name=null) {
		if( !$name ) {
			$name = 'default';
		}
		if( !isset(static::$instances[$name]) ) {
			static::make($name);
		}
		return static::$instances[$name];
	}