Get the namecpase of the foreign model.

@param string $modelName

@return string
17965
protected function getModelNamespace($modelName)
    {
        $path = Helpers::getAppNamespace() . rtrim(Config::getModelsPath(), '\\');

        return $path . '\\' . $modelName;
    }
926985
public function getAttributeNameForColumn($columnName)
    {
        if (!empty($this->mappings)) {
            if (isset($this->mappings[$columnName])) {
                return $this->mappings[$columnName];
            }
        }

        return $columnName;
    }
1124009
protected function getModelNamespace($modelPath)
    {
        $appNamespace = trim($this->getAppNamespace(), '\\');
        $modelNamespace = str_replace('/', '\\', $appNamespace.'/'.ucfirst($modelPath));
        $modelNamespace = trim($modelNamespace, '\\');
        return $modelNamespace == 'App\\' ? 'App' : $modelNamespace;
    }
171783
protected function getEntity($modelName, $primaryModelClass) {
		if ($this->getConfig(static::CONFIG_PLUGIN) && $modelName !== $primaryModelClass && !strpos($modelName, '.')) {
			$modelName = $this->getConfig(static::CONFIG_PLUGIN) . '.' . $modelName;
		}

		try {
			$table = TableRegistry::get($modelName);
			$entityClassName = $table->getEntityClass();
		} catch (Exception $exception) {
			return '\Cake\ORM\Entity';
		}

		return $entityClassName;
	}
1036031
public function getName()
	{
		if(false === isset(self::$modelNameMap[$this->revision])) {
            return 'unknown';
        }

		return self::$modelNameMap[$this->revision];
	}
1131048
protected function _getForeignKey(Table $table, string $modelName) : string
    {
        foreach ($table->associations() as $association) {
            if ($modelName !== $association->className()) {
                continue;
            }

            $primaryKey = $association->getForeignKey();
            if (! is_string($primaryKey)) {
                throw new RuntimeException('Primary key must be a string');
            }

            return $primaryKey;
        }

        return '';
    }
1327996
public function relation($relationName)
    {
        if (!$relation = $this->findRelationByName($relationName)) {
            throw new ModelException(sprintf('Unknown relation, relation "%s" not found in model "%s"', $relationName, $this->entity));
        }

        return $relation;
    }
302757
public static function modelAlias($className = null)
    {
        if (is_null($className)) {
            $className = get_called_class();
        } elseif (is_object($className)) {
            $className = get_class($className);
        }
        if (!strncmp($className, ':', 1)) {
            // already an alias
            return $className;
        }
        $class = new ReflectionClass($className);
        if ($class->getNamespaceName() === 'app\models') {
            return ':app\\' . $class->getShortName();
        } elseif (($alias = array_search($class->getNamespaceName(), Yii::$app->modelAliases)) !== false) {
            return $alias . '\\' . $class->getShortName();
        }

        return $className;
    }
927965
protected function getTableNameForClass(string $modelClass): string
    {
        assert(
            $this->getModelSchemas()->hasClass($modelClass),
            "Class `$modelClass` is not found in model Schemas."
        );

        $tableName = $this->getModelSchemas()->getTable($modelClass);

        return $tableName;
    }
601226
private function getModelNameFromClass($model_class)
    {
        if (($pos = strrpos($model_class, '\\')) !== false) {
            return Inflector::pluralize(Inflector::tableize(substr($model_class, $pos + 1)));
        } else {
            return Inflector::pluralize(Inflector::tableize($model_class));
        }
    }
866487
public static function extractModelName($name)
    {
        $name = self::removePostFixWith($name, '_id');

        return ucfirst(studly_case(Str::singular($name)));
    }
1215964
public function objectName($objectName = null)
    {
        if ($objectName === null)
        {
            return $this->_objectName;
        }
        $this->_objectName = $objectName;

        return $this;
    }
833144
public function get_name() {

        if (trim($this->model->name) === '') {
            return $this->get_target()->get_name();

        } else {
            return $this->model->name;
        }
    }
1358616
protected function namespaceModelClass(string $modelClassCandidate): string
    {
        return $this->namespaceClassName(
            $modelClassCandidate,
            (array) config('lighthouse.namespaces.models'),
            function (string $classCandidate): bool {
                return is_subclass_of($classCandidate, Model::class);
            }
        );
    }
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);
    }
737379
private function getOriginalPropertyName($propertyName, ModelIdInterface $modelId)
    {
        $originalPropertyName =
            \trim(\substr($propertyName, \strlen(\str_replace('::', '____', $modelId->getSerialized()) . '_')), '[]');

        return $originalPropertyName ?: null;
    }
932549
public static function getModelClass($name)
    {
        // If the name contains a backslash it is already fully qualified. However in some cases
        // a model might be replaced by a new class and so we must first look to see if this model is
        // mapped and if so return it's replacement instead.
        if (stripos($name, "\\") !== false) {
            $newName = self::getModelNameFromClass($name);

            if ($newName === null) {
                // $name hasn't been registered as a model object. Play safe and return the
                // same class name passed to us.
                return '\\' . ltrim($name, '\\');
            }

            $name = $newName;
        }

        if (self::$modelClassesCache == null) {
            self::$modelClassesCache = [];

            $schemas = self::getAllSchemas();

            self::$modelNamesCache = [];

            foreach ($schemas as $schema) {
                self::$modelClassesCache = array_merge(self::$modelClassesCache, $schema->models);
                self::$modelNamesCache = array_merge(self::$modelNamesCache, $schema->modelClassNames);
            }
        }

        if (isset(self::$modelClassesCache[$name])) {
            return '\\' . ltrim(self::$modelClassesCache[$name], '\\');
        }

        return null;
    }