src/ModuleDependencyResolver.php
private function getComponentDependencyMap(array $modules) : array
    {
        $component_dependency_map = [];
        $child_component_module_list = [];
        foreach($modules as $key => $m)
        {
            $component_type = call_user_func([$m, 'declareComponentType']);

            $required_components = call_user_func([$m, 'requiredComponents']);

            $dependency = [
                $component_type => $required_components,
            ];

            $component_dependency_map = $this->mergeDependencyMap($component_dependency_map, $dependency);

            foreach($required_components as $component_type){
                $component_module = $this->findComponentModuleByType($modules, $component_type);
                if (!$component_module){
                    throw new ModuleDependencyResolverException(
                        'Could not find component module: ' . $component_type . '(required by module: ' . $m . ')'
                    );
                }
                if (!in_array($component_module, $modules)){
                    $child_component_module_list[] = $component_module;
                }
            }
        }

        if (!empty($child_component_module_list)){
            $child_component_dependency_map = $this->getComponentDependencyMap($child_component_module_list);
            $component_dependency_map = $this->mergeDependencyMap($component_dependency_map, $child_component_dependency_map);
        }

        return $component_dependency_map;
    }
private function getComponentDependencyMap(array $modules) : array
    {
        $component_dependency_map = [];
        $child_component_module_list = [];
        foreach($modules as $key => $m)
        {
            $component_type = call_user_func([$m, 'declareComponentType']);

            $required_components = call_user_func([$m, 'requiredComponents']);

            $dependency = [
                $component_type => $required_components,
            ];

            $component_dependency_map = $this->mergeDependencyMap($component_dependency_map, $dependency);

            foreach($required_components as $component_type){
                $component_module = $this->findComponentModuleByType($modules, $component_type);
                if (!$component_module){
                    throw new ModuleDependencyResolverException(
                        'Could not find component module: ' . $component_type . '(required by module: ' . $m . ')'
                    );
                }
                if (!in_array($component_module, $modules)){
                    $child_component_module_list[] = $component_module;
                }
            }
        }

        if (!empty($child_component_module_list)){
            $child_component_dependency_map = $this->getComponentDependencyMap($child_component_module_list);
            $component_dependency_map = $this->mergeDependencyMap($component_dependency_map, $child_component_dependency_map);
        }

        return $component_dependency_map;
    }
private function getComponentDependencyMap ( array $ modules ) : array { $ component_dependency_map = [ ] ; $ child_component_module_list = [ ] ; foreach ( $ modules as $ key => $ m ) { $ component_type = call_user_func ( [ $ m , 'declareComponentType' ] ) ; $ required_components = call_user_func ( [ $ m , 'requiredComponents' ] ) ; $ dependency = [ $ component_type => $ required_components , ] ; $ component_dependency_map = $ this -> mergeDependencyMap ( $ component_dependency_map , $ dependency ) ; foreach ( $ required_components as $ component_type ) { $ component_module = $ this -> findComponentModuleByType ( $ modules , $ component_type ) ; if ( ! $ component_module ) { throw new ModuleDependencyResolverException ( 'Could not find component module: ' . $ component_type . '(required by module: ' . $ m . ')' ) ; } if ( ! in_array ( $ component_module , $ modules ) ) { $ child_component_module_list [ ] = $ component_module ; } } } if ( ! empty ( $ child_component_module_list ) ) { $ child_component_dependency_map = $ this -> getComponentDependencyMap ( $ child_component_module_list ) ; $ component_dependency_map = $ this -> mergeDependencyMap ( $ component_dependency_map , $ child_component_dependency_map ) ; } return $ component_dependency_map ; }
@param string[] $modules

@return array

@throws ModuleDependencyResolverException
@param string [] $modules