get all controllers
@param  string $namespace 命名空间
@return Controller[]
193463
public function getControllers($namespace=null)
	{
	    if (null === $namespace) {
	        return $this->controllers;
	    }
	    
	    $controllers = [];
	    foreach ($this->controllers as $name => $controller) {
	        if ($this->extractNamespace($name, substr_count($namespace, ':') + 1) === $namespace) {
	            $controllers[$name] = $controller;
	        }
	    }
	    
	    return $controllers;
	}
1235270
protected function getNamespaceFromWechatAppId($namespace)
    {
        if (substr($namespace, 0, 2) != 'wx') {
            return false;
        }

        wei()->logger->debug('Got wechat appId', ['appId' => $namespace]);

        $appId = wei()->wechatAccount()->select('appId')->fetchColumn(['applicationId' => $namespace]);
        if (!$appId) {
            return false;
        }

        $namespace = wei()->appRecord()->select('name')->fetchColumn(['id' => $appId]);
        wei()->logger->debug('Convert wechat appId to namespace', ['namespace' => $namespace]);

        return $namespace;
    }
1000400
public function getNextComponent( $namespace) {
        $namespaceComponents = explode( '\\', $namespace);
        $class_x = explode( '\\', $this->class);

        while( array_shift( $namespaceComponents)){
            array_shift( $class_x);
        }

        return array_shift( $class_x);
    }
719886
public function getControllerInstance($class, $namespace = '')
    {
        if (isset($this->complement['namespaces'])) {
            if (isset($this->complement['namespaces'][$namespace])) {
                $namespace = $this->complement['namespaces'][$namespace];

                $_class = $namespace . $class;

                if (class_exists($_class)) {
                    return call_user_func([$_class, 'getInstance']);
                }

                return false;
            }

            foreach ($this->complement['namespaces'] as $key => $namespace) {
                $instance = $namespace . $class;
                if (class_exists($instance)) {
                    return call_user_func([$instance, 'getInstance']);
                }
            }
        }

        return false;
    }
115059
public function namespace(string $namespace, string $alias = null) : Manager
    {
        $this->namespaces[] = [trim($namespace, '\\'), trim($alias, '\\')];

        return $this;
    }
1076232
protected function getControllerName($name, $namespace)
    {
        if (empty($namespace)) {
            return $name;
        }

        $path = Helpers::postFixWith($namespace, '\\');

        return Helpers::convertSlashToBackslash($path . $name);
    }
503178
public function getNamespaces()
    {
        $namespaces = [];

        foreach ($this->paths as $namespace => $paths) {
            if (count($paths)) {
                $namespaces[] = $namespace;
            }
        }

        return $namespaces;
    }
998860
public static function get($controllerClass) {
        if (!isset(self::$controllers[$controllerClass])) {
            if (class_exists($controllerClass)) {
                $reflectionClass = new ReflectionClass($controllerClass);
                self::$controllers[$controllerClass] = $reflectionClass->isAbstract()? $controllerClass : (new $controllerClass);
            }
            else {
                self::$controllers[$controllerClass] = null;
            }
        }
        return self::$controllers[$controllerClass];
    }
792361
protected function getClassNamesInNamespace($namespace)
    {
        $affectedViewHelperClassNames = [];

        $allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass(AbstractViewHelper::class);
        foreach ($allViewHelperClassNames as $viewHelperClassName) {
            if ($this->reflectionService->isClassAbstract($viewHelperClassName)) {
                continue;
            }
            if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) {
                $affectedViewHelperClassNames[] = $viewHelperClassName;
            }
        }
        sort($affectedViewHelperClassNames);
        return $affectedViewHelperClassNames;
    }
1024960
private function getServiceFromNamespaces($controllerClass)
    {
        foreach ($this->get(self::KEY_NAMESPACES) as $namespace) {
            $fullClass = sprintf('%s\\%s', $namespace, $controllerClass);
            if (class_exists($fullClass)) {
                return new $fullClass();
            }
        }
        throw new Exception('Controller class '.$controllerClass.' was not found in any listed namespace.');
    }
88978
public function filterNamespace( $namespaceName) {
        $FilteredClasses = [];
        foreach( $this->loadedClasses as $loadedClass){
            if( 0 == substr_compare( $loadedClass, $namespaceName, 0, strlen( $namespaceName))){
                $FilteredClasses[] = $loadedClass;
            }
        }
        $this->loadedClasses = $FilteredClasses;
    }
585774
private function getByNamespace($namespace)
    {
        $this->checkForNonEmptyNamespace($namespace);

        if (!isset($this->configurations[$namespace])) {
            $this->configurations[$namespace]
                = $this->retrieveConfigurationFromTypoScriptSetup($namespace);
        }

        return $this->configurations[$namespace];
    }
1226645
public function new_route_controller( $namespace ) {
		// Do we want to auto start our controllers?
		if ( $this->config['routing']['auto_start_controllers'] ) {
			// Let's get our class name from the namespace
			$name_parts = explode( '/', $namespace ); 

			// Let's convert our url endpoint name to a legit classname
			$name_parts = array_map(
				function( $string ) {
					$string = str_replace( '-', '_', $string ); // Turn all hyphens to underscores
					$string = str_replace( '_', ' ', $string ); // Turn all underscores to spaces (for easy casing)
					$string = ucwords( $string ); // Uppercase each first letter of each "word"
					$string = str_replace( ' ', '', $string ); // Remove spaces. BOOM! Zend-compatible camel casing

					return $string;
				},
				$name_parts
			);

			// Create a callable classname
			$classname = implode( '\\', $name_parts );
			$class = $this->config['routing']['controller_base_namespace'] . $classname;

			// Does the class exist? (Autoload it if its not loaded/included yet)
			if ( class_exists( $class, true ) ) {
				// Instanciate the controller and keep an easy reference to it
				$this->controller = new $class( $this->request, $this->response, $this->service, $this );
			}
		}

		return null;
	}
754991
public function getControllerNamespaces()
	{
	    $names = [];
	    foreach ($this->controllers as $controller) {
	        $names = array_merge($names, StringHelper::explodeAllPrefixs($controller->getName()));
	        
	        foreach ($controller->getAliases() as $alias) {
	            $names = array_merge($names, StringHelper::explodeAllPrefixs($alias));
	        }
	    }
	    
	    return array_values(array_unique(array_filter($names)));
	}
202531
public static function getCapabilities(string $controllerName = null, array $actions = []): array
    {
        $result = [];

        if (empty($controllerName)) {
            return $result;
        }

        $skipControllers = Configure::read('RolesCapabilities.accessCheck.skipControllers');
        if (is_callable([$controllerName, 'getSkipControllers'])) {
            $skipControllers = array_merge($skipControllers, $controllerName::getSkipControllers());
        }

        if (in_array($controllerName, $skipControllers)) {
            return $result;
        }

        $actions = static::getActions($controllerName, $actions);

        if (empty($actions)) {
            return $result;
        }

        // get controller table instance
        $table = static::getControllerTableInstance($controllerName);

        $result = static::getCapabilitiesForAction($table, $controllerName, $actions);

        return $result;
    }
474546
public function getNamespace($namespace)
    {
        $classes = [];
        $definitions = $this->classes->extract();

        foreach (array_keys($definitions) as $class) {
            if (strpos($class, $namespace, 0) === 0) {
                $classes[$class] = $this->get($class);
            }
        }

        return $classes;
    }
621992
protected function _getControllers()
	{
		if( $this->_controllers === array() )
		{
			$subFolder = str_replace( '_', DIRECTORY_SEPARATOR, $this->_getClassPrefix() );

			foreach( $this->_cntlPaths as $path => $list )
			{
				foreach( $list as $relpath )
				{
					$path .= DIRECTORY_SEPARATOR . $relpath . DIRECTORY_SEPARATOR . $subFolder;

					if( is_dir( $path ) ) {
						$this->_addControllers( new DirectoryIterator( $path ) );
					}
				}
			}
		}

		return $this->_controllers;
	}