Return a model from the container.

@param string $sModelName     The model name
@param string $sComponentName The name of the component which provides the model

@return Base
@throws FactoryException
165162
public static function model(string $sModelName, ?string $sComponentName = ''): Base
    {
        return static::getServiceOrModel(
            static::$aLoadedItems['MODELS'],
            'models',
            $sModelName,
            $sComponentName,
            array_slice(func_get_args(), 2)
        );
    }
1197767
public function getService( $serviceName ) {

        if ( empty( $this->services[ $serviceName ] ) ) {
            $this->services[ $serviceName ] = $this->factorySyncService( $serviceName );
        }

        if ( ! $this->services[ $serviceName ] instanceof SyncService ) {
            throw new Exception( Yii::t( 'SyncSocial', 'Component service must be instance of SyncService class' ) );
        }

        return $this->services[ $serviceName ];
    }
3835
public static function factory(IComponent $component, array $events, $callbackOnSuccess = 'onSuccess', $callbackOnException = 'onException'): IEventContainer
    {
        $instance = new self($component, $events, $callbackOnSuccess, $callbackOnException);
        return $instance;
    }
807034
protected function _domainModelFactory()
    {
        if (empty($this->_domainModelName) || !class_exists($this->_domainModelName)) {
            throw new \Exception('Domain model class does not exit: ' . $this->_domainModelName, 500);
        }
        return new $this->_domainModelName();
    }
596269
protected function _getSchemaForModel($modelName = null) {
		if (empty($modelName)) {
			return null;
		}

		$modelName = (string)$modelName;
		$cached = $this->_getSchemaCache($modelName);
		if ($cached !== null) {
			return $cached;
		}

		$modelObj = ClassRegistry::init($modelName, true);
		if ($modelObj === false) {
			return null;
		}

		$defaultSchema = [
			'type' => 'string',
			'null' => false,
			'default' => null,
			'length' => null,
		];
		$result = $modelObj->schema();
		$virtualFields = $modelObj->getVirtualField();
		if (!empty($result) && !empty($virtualFields)) {
			foreach ($virtualFields as $virtualFieldName => $virtualFieldValue) {
				$result[$virtualFieldName] = $defaultSchema;
			}
		}
		$this->_setSchemaCache($modelName, $result);

		return $result;
	}
809434
function (name) {
    if (!this.instances[name]) {
      this.instances[name] = DevFixturesModel.create({name: name});
    }
    return this.instances[name];
  }
280498
public function modelFactory($modelName) {
        $modelClass = "\\Modules\\" . RouteController::$currentRoute['module'] . "\\Models\\" . $modelName;

        if (class_exists($modelClass)) {
            return new $modelClass(RouteController::$currentRoute);
        } elseif (class_exists("\\Base\\models\\" . $modelName)) {
            $baseModelClass = "\\Base\\models\\" . $modelName;
            return new $baseModelClass(RouteController::$currentRoute);
        } else {
            HookManager::call("handleModel", $modelName);
        }
    }
658874
public function getConstructor($sClassName)
    {
        $constructorClassName = $this->formConstructorClass($sClassName);
        if (!class_exists($constructorClassName)) {
            $constructorClassName = $this->formConstructorClass('Object');
        }

        return new $constructorClassName($sClassName);
    }
1146336
protected function autoLoadDefaults($sNamespace, $sPath, $sComponent)
    {
        $sClassNamespace = '\\' . $sNamespace . 'FormBuilder\\DefaultValue\\';
        $sPath           = $sPath . 'src/FormBuilder/DefaultValue/';

        if (is_dir($sPath)) {

            $aFiles = directory_map($sPath);
            foreach ($aFiles as $sFile) {
                $sClassName = $sClassNamespace . basename($sFile, '.php');
                if (class_exists($sClassName)) {
                    $this->aAvailable[] = (object) [
                        'slug'      => $sClassName,
                        'label'     => $sClassName::LABEL,
                        'component' => 'DefaultValue' . basename($sFile, '.php'),
                        'provider'  => $sComponent,
                        'instance'  => null,
                    ];
                }
            }
        }
    }
1141299
function (sComponent, a, b, c, d) {
            log("factory.object.getcomponentversion: " + sComponent);
            var v = moduleversion;

            switch (sComponent.toLowerCase()) {
                case "scriptx.factory":
                    v = emulatedVersion;
                    break;

                case "scriptx.factory.services":
                    v = moduleversion;
                    break;

                case "meadco.secmgr":
                    try {
                        v = module.secmgr.version;
                    } catch (e) { v = "0.0.0.0"; }
                    break;

                case "meadco.triprint":
                    try {
                        v = MeadCo.ScriptX.Print.HTML.version;
                    } catch (e) { v = "0.0.0.0"; }
                    break;
            }

            v = v.split(".");
            a[0] = v[0];
            b[0] = v[1];
            c[0] = v[2];
            d[0] = v[3];
        }
204036
public static function getInstance($cloneInstance = false): Factory
	{	
		if ($cloneInstance === true || self::$cloneInstances === true)
		{
			return clone self::$sharedFactoryInstance;
		}

		return self::$sharedFactoryInstance;
	}
1151125
protected function propertyFactory()
    {
        if ($this->propertyFactory === null) {
            throw new RuntimeException(sprintf(
                'Model [%s] does not have a property factory.',
                get_class($this)
            ));
        }

        return $this->propertyFactory;
    }
389106
public function templateFactory()
    {
        if (!isset($this->templateFactory)) {
            throw new RuntimeException(sprintf(
                'Template Factory is not defined for [%s]',
                get_class($this)
            ));
        }

        return $this->templateFactory;
    }
804415
protected function autoLoadTypes($sNamespace, $sPath, $sComponent)
    {
        $sClassNamespace = '\\' . $sNamespace . 'FormBuilder\\FieldType\\';
        $sPath           = $sPath . 'src/FormBuilder/FieldType/';

        if (is_dir($sPath)) {
            Factory::helper('directory');
            $aFiles = directory_map($sPath);
            foreach ($aFiles as $sFile) {
                $sClassName = $sClassNamespace . basename($sFile, '.php');
                if (class_exists($sClassName)) {
                    $this->aAvailable[] = (object) [
                        'slug'               => $sClassName,
                        'label'              => $sClassName::LABEL,
                        'component'          => 'FieldType' . basename($sFile, '.php'),
                        'provider'           => $sComponent,
                        'instance'           => null,
                        'is_selectable'      => $sClassName::IS_SELECTABLE,
                        'can_option_select'  => $sClassName::SUPPORTS_OPTIONS_SELECTED,
                        'can_option_disable' => $sClassName::SUPPORTS_OPTIONS_DISABLE,
                    ];
                }
            }
        }
    }
299775
public function getModel()
    {
        if(!$this->_model instanceof KModelInterface)
        {
            if(!($this->_model instanceof KObjectIdentifier)) {
                $this->setModel($this->_model);
            }

            $this->_model = $this->getObject($this->_model);

            if(!$this->_model instanceof KModelInterface)
            {
                throw new UnexpectedValueException(
                    'Model: '.get_class($this->_model).' does not implement KModelInterface'
                );
            }
        }

        return $this->_model;
    }
192829
public function factory($name)
    {
        if (isset($this->factories[$name])) {
            return $this->factories[$name];
        }

        if (class_exists($class = $this->inflect($name))) {
            return $this->factories[$name] = new $class();
        }

        throw new InvalidArgumentException("Unsupported factory [$name].");
    }
52262
public function callComponent($componentName)
    {
        if (!isset($this->components[$componentName])) {
            $requiredInterface = isset(static::$defaultComponents[$componentName][1])
                ? static::$defaultComponents[$componentName][1]
                : null;
            $componentConfig = isset(static::$defaultComponents[$componentName][2])
                ? static::$defaultComponents[$componentName][2]
                : [];
            if (isset($this->config['components'][$componentName])){
                $componentConfig = array_merge($componentConfig, $this->config['components'][$componentName]);
            }
            if (isset($componentConfig['class'])) {
                $componentClassName = $componentConfig['class'];
            } else {
                $componentClassName = isset(static::$defaultComponents[$componentName][0])
                    ? static::$defaultComponents[$componentName][0]
                    : null;
            }
            unset($this->config['components'][$componentName]);
            if (isset($componentConfig['class']))
            unset($componentConfig['class']);
            if ($componentClassName) {
                $instance = new $componentClassName($componentConfig, $this);
                if (null === $requiredInterface || ($instance instanceof $requiredInterface)) {
                    $this->components[$componentName] = $instance;
                } else {
                    throw new InvalidInterfaceException([$componentName, $componentClassName, $requiredInterface]);
                }
            } else {
                throw new UnknownComponentException($componentName);
            }
        }
        return $this->components[$componentName];
    }