For Minerva to be pulled out of the MobileFrontend repository the skin portion needs to be agnostic to the existence of MobileFrontend.
MobileContext will stay in MobileFrontend so any references to this class should be ported to MobileFrontend.skin.hooks.
---
There appear to be a handful of things that SkinMinerva gets from MobileContext:
# Whether the user is a member of the beta group (or "MobileFrontend is in beta mode" as we like to say) – seriously, we should align our language with that of the codebase…
# Whether the mobile view should be displayed (see MobileContext#shouldDisplayMobileView).
# Access to the global configuration, i.e. an instance of GlobalVarConfig with the default 'wg' prefix.
# Access to something capable of generating URLs for the mobile domain (see MobileContext#getMobileUrl).
1, 2, and 3 are just state. 4 should be extracted into its own class, which would hide away the complexity of generating URLs and for which domains. All of them, however, could be injected:
```lang=php,name=includes/SkinMinerva.php
public function __construct( $shouldDisplayMobileView, $isBetaGroupMember, Config $config, Router $router ) {
$this->isMobileMode = $shouldDisplayMobileView;
$this->isBetaGroupMember = $isBetaGroupMember;
$this->config = $config;
$this->router = $router;
// ...
}
```
### Plan (YMMV)
# Audit occurrances of `$this->isMobileMode` (according to T148197#2760151 the skin shouldn't be varying its behaviour)
# Inject an instance of `GlobalVarConfig` via the constructor.
# [Register a factory function with `SkinFactory`](https://github.com/wikimedia/mediawiki/blob/master/includes/skins/SkinFactory.php#L54-L73).
# Replace all calls to `SkinMinerva#getMFConfig` with `$this->config`.
# Create `MobileFrontend\Router` class, which has the following shape, and inject it via the constructor.
```lang=php,name=includes/Router.php
class Router {
public function getLoginUrl( array $returnTo ) {
}
public function getLogoutUrl( array $returnTo ) {
}
}
```
# Replace all calls to `MobileContext#getMobileUrl` with the appropriate `Router` method.