Load the model of current component by alias

@param type $mdlname
@return null|\BModel
502040
public function LoadModel($mdlname=''){
		if(empty($mdlname)){
			bimport('mvc.model');
			return new BModel();
			}
		$fn=BCOMPONENTSAPPLICATIONPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
		if(!file_exists($fn)){
			$fn=BCOMPONENTSFRAMEWORKPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
			}
		$class='Model_'.$this->componentname.'_'.$mdlname;
		if(!file_exists($fn)){
			echo('File "'.$fn.'" does not exist!');
			return NULL;
			}
		require_once($fn);
		$model=new $class;
		$model->controller=$this;
		return $model;
		}
719802
private function replaceModelName($content)
    {
        $newContent = '';
        $content = str_replace('new %modelName%', 'new '.$this->model, $content);
        $content = str_replace('%StaticModelName%', $this->model, $content);
        $content = str_replace('new %StaticModelName%()', $this->model, $content);
        $newContent = str_replace('%modelName%', Inflector::tabilize($this->model), $content);

        return $newContent;
    }
1216136
public function getModelJoinByTableName($tableName) {
        foreach ($this->joins as $join) {
            if ($join instanceof ModelJoin && $join->getTableMap()->getName() == $tableName) {
                return $join;
            }
        }

        return null;
    }
1244140
public function load(string $alias): ?bool
    {
        if (\strpos($alias, self::FACADE_NAMESPACE) === 0) {
            return $this->loadFacade($alias);
        }

        if (isset($this->aliases[$alias])) {
            return \class_alias($this->aliases[$alias], $alias);
        }

        return null;
    }
313404
public function setModelName($modelName) {
    
    if (!class_exists($modelName))
      throw new Exception("Model '{$modelName}' could not be found");
    
    $model = new \ReflectionClass($modelName);
    
    if (!$model->implementsInterface('\Phalcon\Mvc\ModelInterface'))
      throw new Exception("'{$modelName}' must be an instance of Phalcon\Mvc\ModelInterface");
    
    $this->modelname = $modelName;
    return $this;
  }
579158
public function get_by_name( $name )
    {
        $filtered = $this->filter(function($c) use ($name) {
            return $c instanceof ValueComponentInterface && $c->name === $name;
        });
        if(count($filtered) < 1)
        {
            throw new \RuntimeException("No component with the name <b>$name</b> could be found.");
        }
        return $filtered[0];
    }
1138729
protected function loadFile($filename)
    {
        // Save this so we can modify it and still delegate to parent
        $originalFilename = $filename;

        if (isset($this->aliases[$filename])) {
            $filename = $this->aliases[$filename];
        }

        if ($this->isModular($filename)) {
            // Description is modular, this class should handle it
            return $this->loadModular($filename);
        }

        // Description isn't modular, delegate to parent with the
        // original (unmodified) value of $filename
        return parent::loadFile($originalFilename);
    }
446977
protected function getModelName($name = null)
    {
        $name = isset($name) ? $name : $this->resource;

        //return ucwords(camel_case($this->getResourceName($name)));

        return str_singular(ucwords(camel_case(class_basename($name))));
    }
1278445
public function load($alias)
    {
        if (static::$facadeNamespace && strpos($alias, static::$facadeNamespace) === 0) {
            $this->loadFacade($alias);

            return true;
        }

        if (isset($this->aliases[$alias])) {
            return class_alias($this->aliases[$alias], $alias);
        }
    }
359662
public function get($modelName)
    {
        $modelNamespace = Configuration::read('mvc.model.namespace');
        $modelNamespace = $modelNamespace . '\\' . ucFirst($modelName);
        if (!class_exists($modelNamespace)) {
            trigger_error('Model "' . $modelNamespace . '" doesn\'t exist.', E_USER_ERROR);
            return false;
        }
        return new $modelNamespace();
    }
1331648
public function setModelName($modelName)
    {
        if (0 === strpos($modelName, '\\')) {
            $this->modelName = substr($modelName, 1);
        } else {
            $this->modelName = $modelName;
        }
        if ($this->modelName && !$this->modelTableMapName) {
            $this->modelTableMapName = constant($this->modelName . '::TABLE_MAP');
        }
        if (!$this->tableMap && $this->modelName) {
            $this->tableMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName())->getTableByPhpName($this->modelName);
        }

        return $this;
    }
46804
public static function make($modelName)
    {
        if (! static::isConfigPublished()) {
            return null;
        }

        $transformerName = Config::get('transformers.transformers')[$modelName];

        return App::make($transformerName);
    }
814222
public function getTableName($modelName)
    {
        if (! isset($this->_unionModels[$modelName])) {
            return null;
        }

        $model = $this->_unionModels[$modelName];

        if ($model instanceof \MUtil_Model_TableModel) {
            return $model->getTableName();
        }
    }
1079230
public function getModel(string $name = '')
    {
        if (empty($name)) {
            $name = $this->getComponentsName();
        }

        // Create a model instance from a different app?
        $model = $this->MVCFactory($name, 'Model');

        return $model;
    }
45705
protected function getModelTpl($modelClassName, $tableName)
    {
        $modelTpl = str_replace(CodeTpl::CLASS_NAME_TAG, $modelClassName, CodeTpl::MODEL_TPL);

        /**
 * @var \PDOStatement $statement 
*/
        $statement = Connection::component()->read_conn->prepare('desc ' . $tableName);
        if ($result = $statement->execute()) {
            $fields = $statement->fetchAll();

            if (!$fields) {
                throw new ParamException(ErrorMsg::INVALID_PARAM);
            }

            //Assemble Attributes & Labels
            $primaryKeyAttr = '';
            $attributes = '';

            $primaryKeyLabel = '';
            $labels = '';

            $primaryKey = '';

            $primaryKeyComment = '';
            $propertyComments = '';

            $setter = '';
            $getter = '';

            foreach ($fields as $field) {
                $attrName = $field['Field'];
                $defaultValue = $this->formatValue($field['Default'], $field['Type']);
                $label = $this->formatLabel($attrName);
                $commentType = $this->getCommentType($field['Type']);
                $camelAttrName = $this->formatAttr($attrName);

                //Setter
                $setter .= <<<EOF
    public function set{$camelAttrName}(\$value)
    {
        \$this->{$attrName} = \$value;
        return \$this;
    }
EOF;
                $setter .= (str_repeat(PHP_EOL, 2));

                //Getter
                $getter .= <<<EOF
    public function get{$camelAttrName}()
    {
        return \$this->{$attrName};
    }
EOF;
                $getter .= (str_repeat(PHP_EOL, 2));

                if ($field['Key'] == 'PRI') {
                    //Primary Key
                    $primaryKey = $attrName;

                    //Primary Key Attribute
                    $primaryKeyAttr = <<<EOF
    '{$attrName}' => {$defaultValue},
EOF;
                    $primaryKeyAttr .= PHP_EOL;

                    //Primary Key Label
                    $primaryKeyLabel = <<<EOF
    '{$attrName}' => '{$label}',
EOF;
                    $primaryKeyLabel .= PHP_EOL;

                    //Primary Key Comment
                    $primaryKeyComment = <<<EOF
 * @property {$commentType} \${$attrName}
EOF;
                    $primaryKeyComment .= PHP_EOL;
                } else {
                    //Attributes
                    $attributes .= <<<EOF
        '{$attrName}' => {$defaultValue},
EOF;
                    $attributes .= PHP_EOL;

                    //Labels
                    $labels .= <<<EOF
        '{$attrName}' => '{$label}',
EOF;
                    $labels .= PHP_EOL;

                    //Property Comment
                    $propertyComments .= <<<EOF
 * @property {$commentType} \${$attrName}
EOF;
                    $propertyComments .= PHP_EOL;
                }
            }
            $modelTpl = str_replace(CodeTpl::ATTRIBUTES_TAG, rtrim($primaryKeyAttr . $attributes, PHP_EOL), $modelTpl);
            $modelTpl = str_replace(CodeTpl::LABELS_TAG, rtrim($primaryKeyLabel . $labels, PHP_EOL), $modelTpl);
            $modelTpl = str_replace(
                CodeTpl::PROPERTY_COMMENTS_TAG,
                rtrim($primaryKeyComment . $propertyComments, PHP_EOL),
                $modelTpl
            );
            $modelTpl = str_replace(CodeTpl::PRIMARY_KEY_TAG, $primaryKey, $modelTpl);
            $modelTpl = str_replace(CodeTpl::SETTER, $setter, $modelTpl);
            $modelTpl = str_replace(CodeTpl::GETTER, rtrim($getter, PHP_EOL), $modelTpl);
        }

        return str_replace(CodeTpl::TABLE_NAME_TAG, $tableName, $modelTpl);
    }
314105
public function requireModel($model, &$data, $prefix = null)
    {
        $class = null;
        $name = (null !== $prefix) ? $prefix : substr($model, strlen(explode('_', $model)[0]) + 7);
        
        foreach ($this->array_prefix as $k => $ap) {
            if (strrpos($ap, $name) === (strlen($ap) - strlen($name))) {
                unset($this->array_prefix[$k]);
                $class = clone $this->container->get($model);
                $class->setPrefix($prefix);
                $class->setArrayPrefix($this->array_prefix);
                $class->setParentModel($this);
                $class->exchangeArray($data);
                if (! $class->Keep()) {
                    return new IsNull();
                }
                break;
            }
        }
        
        return $class;
    }
1296618
public static function parseName($model) {
        return self::cache(array(__METHOD__, $model), function() use ($model) {
            list($plugin, $model) = pluginSplit($model);
            $core = Configure::read('Admin.coreName');

            if (!$plugin) {
                $plugin = $core;
            }

            $plugin = Inflector::camelize($plugin);
            $model = Inflector::camelize($model);
            $class = $model;

            if ($plugin !== $core) {
                $class = $plugin . '.' . $class;
            }

            return array(
                $plugin, // plugin name, includes Core
                $model, // model class name
                $plugin . '.' . $model, // plugin and model, includes Core
                $class // plugin and model, excludes Core
            );
        });
    }