Hygiene: Simplify Nearby menu item registration

The Special:Nearby page is only available if wgMFNearby is
enabled so the first 2 checks are identical.

If the page is enabled, we should be able to assume the
sysop knows what they are doing and avoid all  these
unnecessary checks. It seems foolish to also check the
existence of Geodata or a NearbyEndpoint

Additional change:
* Don't use deprecated SpecialPageFactory. Use the service
instead.

Change-Id: I3a4b8fa55fc7f29c90f7173d1d973d5f4f759a6b
This commit is contained in:
jdlrobson 2019-01-03 15:08:49 -08:00
parent 4b49da4e6c
commit d8a8410a8d

View file

@ -639,6 +639,7 @@ class SkinMinerva extends SkinTemplate {
protected function getDiscoveryTools() {
$config = $this->getConfig();
$menu = new MenuBuilder();
$factory = MediaWikiServices::getInstance()->getSpecialPageFactory();
// Home link
$menu->insert( 'home' )
@ -662,11 +663,7 @@ class SkinMinerva extends SkinTemplate {
);
// Nearby link (if supported)
if (
SpecialPageFactory::exists( 'Nearby' ) &&
$config->get( 'MFNearby' ) &&
( $config->get( 'MFNearbyEndpoint' ) || class_exists( 'GeoData\GeoData' ) )
) {
if ( $factory->exists( 'Nearby' ) ) {
$menu->insert( 'nearby', $isJSOnly = true )
->addComponent(
$this->msg( 'mobile-frontend-main-menu-nearby' )->escaped(),