Puli\Manager\Factory\FactoryManagerImpl::addGetModuleOrderMethod PHP Метод

addGetModuleOrderMethod() публичный Метод

Adds the getModuleOrder() method.
public addGetModuleOrderMethod ( Puli\Manager\Api\Php\Clazz $class )
$class Puli\Manager\Api\Php\Clazz The factory class model.
    public function addGetModuleOrderMethod(Clazz $class)
    {
        $class->addImport(new Import('Puli\\Discovery\\Api\\Discovery'));
        $class->addImport(new Import('Puli\\Manager\\Api\\Server\\ServerCollection'));
        $class->addImport(new Import('Puli\\UrlGenerator\\Api\\UrlGenerator'));
        $class->addImport(new Import('Puli\\UrlGenerator\\DiscoveryUrlGenerator'));
        $class->addImport(new Import('RuntimeException'));
        $method = new Method('getModuleOrder');
        $method->setDescription("Returns the order in which the installed modules should be loaded\naccording to the override statements.");
        $method->setReturnValue(new ReturnValue('$order', 'string[]', 'The sorted module names.'));
        $moduleOrderString = '';
        if (count($this->modules) > 0) {
            $overrideGraph = DependencyGraph::forModules($this->modules);
            foreach ($overrideGraph->getSortedModuleNames() as $moduleName) {
                $moduleOrderString .= sprintf("\n    %s,", var_export($moduleName, true));
            }
            $moduleOrderString .= "\n";
        }
        $method->addBody("\$order = array({$moduleOrderString});");
        $class->addMethod($method);
    }