container = $container; $this->settings = $settings; $this->extensions = $extensions; $this->db = $db; $this->events = $events; } public function __invoke(Document $document, Request $request) { $settings = $this->settings->all(); $this->events->dispatch( new Deserializing($settings) ); $document->payload['settings'] = $settings; $document->payload['permissions'] = Permission::map(); $document->payload['extensions'] = $this->extensions->getExtensions()->toArray(); $document->payload['displayNameDrivers'] = array_keys($this->container->make('flarum.user.display_name.supported_drivers')); $document->payload['slugDrivers'] = array_map(function ($resourceDrivers) { return array_keys($resourceDrivers); }, $this->container->make('flarum.http.slugDrivers')); $document->payload['phpVersion'] = PHP_VERSION; $document->payload['mysqlVersion'] = $this->db->selectOne('select version() as version')->version; /** * Used in the admin user list. Implemented as this as it matches the API in flarum/statistics. * If flarum/statistics ext is enabled, it will override this data with its own stats. * * This allows the front-end code to be simpler and use one single source of truth to pull the * total user count from. */ $document->payload['modelStatistics'] = [ 'users' => [ 'total' => User::count() ] ]; } }