/** * @event kernel.controller * @priority 9999 * @param FilterControllerEvent $e */ static function onRequest($e) { if ($variants = Submodules::fastInvoke('route_alter_variants')[\Drupal::routeMatch()->getRouteName()] ?? NULL) { foreach ($variants as $variant) { if (!isset($variant['applies']) || is_callable($variant['applies']) && $variant['applies']()) { $e->setController($variant['controller']); break; } } } }
/** * {@inheritdoc} */ public function routes() { $routes = []; foreach (Submodules::fastInvoke('route') as $name => $route) { $route += ['defaults' => [], 'requirements' => [], 'options' => [], 'host' => '', 'schemes' => [], 'methods' => [], 'condition' => '']; $routes[$name] = new Route($route['path'], $route['defaults'], $route['requirements'], $route['options'], $route['host'], $route['schemes'], $route['methods'], $route['condition']); } $dispatcher = \Drupal::service('event_dispatcher'); foreach (_d_submodules_event_map() as $event) { if ('routing.route_alter' === $event[0]) { call_user_func_array([$dispatcher, 'addListener'], $event); } } return $routes; }
/** * @implement theme * @return array */ public static function load() { $themes = []; static::$container = Drupal::getContainer(); foreach (static::getFiles('/^.+\\.themes\\.yml/i') as $file) { $path = dirname($file); $info = static::yamlDecode($file); foreach ($info['themes'] ?? [] as $name => $theme) { if (!isset($theme['variables'])) { $theme['render element'] = $theme['render element'] ?? 'scope'; } $theme['path'] = $path . '/' . ($theme['path'] ?? 'templates'); $theme['template'] = $theme['template'] ?? $name; $theme += ['pattern' => FALSE, 'preprocess functions' => [], 'override preprocess functions' => TRUE]; foreach ($theme['preprocess functions'] as $k => $function) { $theme['preprocess functions'][$k] = Submodules::generateCallbackName($function); } $themes[$name] = $theme; } } return $themes; }
/** * @implement library_info_alter */ static function libraryInfo(&$libraries, $extension) { $libraries += Submodules::fastInvoke('submodule_library_info')[$extension] ?? []; }