Get a namesapce identified by the modelId or modelUri

@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param  modelid
@return common_ext_Namespace
190533
public function getNamespace($modelid)
    {
        $returnValue = null;
    
        if(count($this->namespaces) == 0){
        	$this->getAllNamespaces();	//load the namespaces attribute 
       	}
        
        //get modelId from modelUri
        if(is_string($modelid)){
        	$modelid = array_search($modelid, $this->namespaces);
        }
        
    	//get namespace from modelId
    	if(is_int($modelid)){
        	if(isset($this->namespaces[$modelid])){
        		$returnValue = new common_ext_Namespace($modelid, $this->namespaces[$modelid]);
        	}
        }

        return $returnValue;
    }
226320
private function findModel($model_name, $id = null)
    {
        $model = config('kregel.warden.models.'.$model_name.'.model');
        if (empty($model)) {
            throw new \Exception('There is no model by the name {'.$model_name.'}');
        }
        if (empty($id) | !is_numeric($id)) {
            return new $model();
        }

        return $model::findOrFail($id);
    }
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);
            }
        );
    }
1132301
public function deleteById(string $modelId)
    {
        $deleteResult = $this->getRequest()->request(
            'DELETE',
            $this->getRequestUrl(sprintf('models/%s', $modelId))
        );

        return $deleteResult['status'];
    }
1099068
public function setModel($id, $modelId)
    {
        return $this->put($this->getPath().'/'.rawurlencode($id).'/idModel', array('value' => $modelId));
    }
262330
protected function getModelNamespace($modelName, $modelDirectory)
    {
        if (!empty($modelDirectory)) {
            $modelDirectory = str_finish($modelDirectory, '\\');
        }

        $namespace = Helpers::getAppNamespace() . ltrim(Config::getModelsPath($modelDirectory . $modelName), '\\');

        return rtrim(Helpers::convertSlashToBackslash($namespace), '\\');
    }
732191
@Override
    public String getMetaZoneDisplayName(String mzID, NameType type) {
        if (mzID == null || mzID.length() == 0) {
            return null;
        }
        return loadMetaZoneNames(mzID).getName(type);
    }
1179611
public static function & GetNamespace (
		$name = \MvcCore\ISession::DEFAULT_NAMESPACE_NAME
	) {
		if (!static::GetStarted()) static::Start();
		if (!isset(static::$instances[$name])) {
			static::$instances[$name] = new static($name);
		}
		/** @var $result \MvcCore\Session */
		$result = & static::$instances[$name];
		return $result;
	}
472180
def get_namespace( self, namespace_id, include_history=True ):
        

        cur = self.db.cursor()
        return namedb_get_namespace_ready( cur, namespace_id, include_history=include_history )
1165816
public static String getNamespace(HasMetadata entity) {
    if (entity != null) {
      return getNamespace(entity.getMetadata());
    } else {
      return null;
    }
  }
1124009
protected function getModelNamespace($modelPath)
    {
        $appNamespace = trim($this->getAppNamespace(), '\\');
        $modelNamespace = str_replace('/', '\\', $appNamespace.'/'.ucfirst($modelPath));
        $modelNamespace = trim($modelNamespace, '\\');
        return $modelNamespace == 'App\\' ? 'App' : $modelNamespace;
    }
1073107
public function getModelName($modelName = null)
    {
        $modelName = is_null($modelName) ? $this->argument('name') : $modelName;
        $model_name = ucfirst(class_basename($modelName));
        $plural_model_name = str_plural($model_name);
        $modelPath = $this->getModelPath($modelName);
        $modelNamespace = $this->getModelNamespace($modelPath);

        return $this->modelNames = [
            'model_namespace'           => $modelNamespace,
            'full_model_name'           => $modelNamespace.'\\'.$model_name,
            'plural_model_name'         => $plural_model_name,
            'model_name'                => $model_name,
            'table_name'                => snake_case($plural_model_name),
            'lang_name'                 => snake_case($model_name),
            'collection_model_var_name' => camel_case($plural_model_name),
            'single_model_var_name'     => camel_case($model_name),
            'model_path'                => $modelPath,
        ];
    }
692825
private function modelIs($conjunction, ModelId $modelId)
    {
        if (!empty($this->expression)) {
            $this->expression[] = $conjunction;
        }

        $index              = \count($this->variables);
        $this->expression[] = \sprintf(self::MODEL_IS_EXPRESSION, $index);
        $this->variables[]  = $modelId;
        $this->compiled     = null;

        return $this;
    }
98864
public function get_namespace( $id = true ) {
		if( $id ) {
			return $this->namespace_id;
		} else {
			$namespaces = $this->wiki->get_namespaces();

			return $namespaces[$this->namespace_id];
		}
	}
921147
public ApplicationDescriptor addNamespace(String name, String value)
   {
      model.attribute(name, value);
      return this;
   }
823163
public function getAllNamespaces()
    {
        $returnValue = array();

        
        
        if(count($this->namespaces) == 0){
        	$db = core_kernel_classes_DbWrapper::singleton();
        	$query = 'SELECT modelid, modeluri FROM models';
			$result = $db->query($query);
			
			while ($row = $result->fetch()){	
				$id 	= $row['modelid'];
				$uri 	= $row['modeluri'];
				$this->namespaces[$id] = $uri;
			}
        }
        
        foreach($this->namespaces as $id => $uri){
        	$returnValue[$uri] = new common_ext_Namespace($id, $uri);
        }

        

        return (array) $returnValue;
    }
494177
protected function getModelClass($name)
    {
        $modelClass = $this->getModelNameInput();

        // Generate the model class from the repository class name if not explicitly set
        if ( ! $modelClass) {

            $repositoryClass = str_replace($this->getNamespace($name) . '\\', '', $name);
            $class           = str_replace($this->suffix, '', $repositoryClass);

            $modelClass = str_singular($class);
        }

        // Append the expected models namespace if not namespaced yet
        if (false === strpos($modelClass, '\\')) {
            $modelClass = "{$this->models}\\{$modelClass}";
        }

        return $modelClass;
    }