[MODULES] Fix module manager dev-mode rebuild
This commit is contained in:
parent
0a56061639
commit
c0ce25c352
@ -75,10 +75,11 @@ class SchemaDefDriver extends StaticPHPDriver
|
|||||||
{
|
{
|
||||||
$schema = $class_name::schemaDef();
|
$schema = $class_name::schemaDef();
|
||||||
|
|
||||||
$metadata->setPrimaryTable(['name' => $schema['name'],
|
$metadata->setPrimaryTable([
|
||||||
'indexes' => self::kv_to_name_col($schema['indexes'] ?? []),
|
'name' => $schema['name'],
|
||||||
'uniqueConstraints' => self::kv_to_name_col($schema['unique keys'] ?? []),
|
'indexes' => self::kv_to_name_col($schema['indexes'] ?? []),
|
||||||
'options' => ['comment' => $schema['description'] ?? ''],
|
'uniqueConstraints' => self::kv_to_name_col($schema['unique keys'] ?? []),
|
||||||
|
'options' => ['comment' => $schema['description'] ?? ''],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach ($schema['fields'] as $name => $opts) {
|
foreach ($schema['fields'] as $name => $opts) {
|
||||||
|
@ -137,6 +137,8 @@ class GNUsocial implements EventSubscriberInterface
|
|||||||
HTTPClient::setClient($this->client);
|
HTTPClient::setClient($this->client);
|
||||||
|
|
||||||
if (isset($_ENV['HTTPS']) || isset($_ENV['HTTP_HOST'])) {
|
if (isset($_ENV['HTTPS']) || isset($_ENV['HTTP_HOST'])) {
|
||||||
|
// TODO move to container definition, after removing
|
||||||
|
// this way of doing configuration
|
||||||
DefaultSettings::setDefaults();
|
DefaultSettings::setDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,12 +83,11 @@ class ModuleManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(ContainerBuilder $container)
|
public static function process(?ContainerBuilder $container = null)
|
||||||
{
|
{
|
||||||
$module_paths = array_merge(glob(INSTALLDIR . '/components/*/*.php'), glob(INSTALLDIR . '/plugins/*/*.php'));
|
$module_paths = array_merge(glob(INSTALLDIR . '/components/*/*.php'), glob(INSTALLDIR . '/plugins/*/*.php'));
|
||||||
$module_manager = new self();
|
$module_manager = new self();
|
||||||
$entity_paths = [];
|
$entity_paths = [];
|
||||||
$default_driver = $container->findDefinition('doctrine.orm.default_metadata_driver');
|
|
||||||
foreach ($module_paths as $path) {
|
foreach ($module_paths as $path) {
|
||||||
// 'modules' and 'plugins' have the same length
|
// 'modules' and 'plugins' have the same length
|
||||||
$type = ucfirst(preg_replace('%' . INSTALLDIR . '/(component|plugin)s/.*%', '\1', $path));
|
$type = ucfirst(preg_replace('%' . INSTALLDIR . '/(component|plugin)s/.*%', '\1', $path));
|
||||||
@ -96,17 +95,19 @@ class ModuleManager
|
|||||||
$module = basename($dir);
|
$module = basename($dir);
|
||||||
$fqcn = "\\{$type}\\{$module}\\{$module}";
|
$fqcn = "\\{$type}\\{$module}\\{$module}";
|
||||||
$module_manager->add($fqcn, $path);
|
$module_manager->add($fqcn, $path);
|
||||||
if (file_exists($dir = $dir . '/Entity') && is_dir($dir)) {
|
if (!is_null($container) && file_exists($dir = $dir . '/Entity') && is_dir($dir)) {
|
||||||
$entity_paths[] = $dir;
|
$entity_paths[] = $dir;
|
||||||
$default_driver->addMethodCall(
|
$container->findDefinition('doctrine.orm.default_metadata_driver')->addMethodCall(
|
||||||
'addDriver',
|
'addDriver',
|
||||||
[new Reference('app.core.schemadef_driver'), "{$type}\\{$module}\\Entity"]
|
[new Reference('app.core.schemadef_driver'), "{$type}\\{$module}\\Entity"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$container->findDefinition('app.core.schemadef_driver')
|
if (!is_null($container)) {
|
||||||
->addMethodCall('addPaths', ['$paths' => $entity_paths]);
|
$container->findDefinition('app.core.schemadef_driver')
|
||||||
|
->addMethodCall('addPaths', ['$paths' => $entity_paths]);
|
||||||
|
}
|
||||||
|
|
||||||
$module_manager->preRegisterEvents();
|
$module_manager->preRegisterEvents();
|
||||||
|
|
||||||
@ -132,6 +133,7 @@ class ModuleManager
|
|||||||
$time = file_exists(CACHE_FILE) ? filemtime(CACHE_FILE) : 0;
|
$time = file_exists(CACHE_FILE) ? filemtime(CACHE_FILE) : 0;
|
||||||
|
|
||||||
if (F\some($rdi, function ($e) use ($time) { return $e->getMTime() > $time; })) {
|
if (F\some($rdi, function ($e) use ($time) { return $e->getMTime() > $time; })) {
|
||||||
|
Log::info('Rebuilding plugin cache at runtime. This means we can\'t update DB definitions');
|
||||||
self::process();
|
self::process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user