Added a quick and dirty way to guess in an inactive module has a config

route
This commit is contained in:
Franck Allimant
2014-01-21 23:56:47 +01:00
parent 3b3e993514
commit c9c489a76b

View File

@@ -194,21 +194,33 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
$hasConfigurationInterface = false; $hasConfigurationInterface = false;
/* first test if module defines it's own config route */
$routerId = "router." . $module->getBaseDir(); /* first test if module defines it's own config route */
if ($this->container->has($routerId)) { if ($module->getActivate()) {
try { // Works only fo activated modules - see Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass
if ($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) { $routerId = "router." . $module->getBaseDir();
if ($this->container->has($routerId)) {
try {
if ($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) {
$hasConfigurationInterface = true;
}
} catch (ResourceNotFoundException $e) {
/* $hasConfigurationInterface stays false */
}
}
/* if not ; test if it uses admin inclusion : module_configuration.html */
if (false === $hasConfigurationInterface) {
if (file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) {
$hasConfigurationInterface = true; $hasConfigurationInterface = true;
} }
} catch (ResourceNotFoundException $e) {
/* $hasConfigurationInterface stays false */
} }
} }
else {
// Make a quick and dirty test on the module's routing.xml file
$routing = @file_get_contents($module->getAbsoluteBaseDir() . DS . "Config" . DS . "routing.xml");
/* if not ; test if it uses admin inclusion : module_configuration.html */ if ($routing && strpos($routing, '/admin/module/') !== false) {
if (false === $hasConfigurationInterface) {
if (file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) {
$hasConfigurationInterface = true; $hasConfigurationInterface = true;
} }
} }