Changeset View
Changeset View
Standalone View
Standalone View
src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | $cache->deleteKeys( | ||||
self::KEY_DEFAULT, | self::KEY_DEFAULT, | ||||
)); | )); | ||||
} | } | ||||
public static function getSpacesExist() { | public static function getSpacesExist() { | ||||
return (bool)self::getAllSpaces(); | return (bool)self::getAllSpaces(); | ||||
} | } | ||||
public static function getViewerSpacesExist(PhabricatorUser $viewer) { | |||||
if (!self::getSpacesExist()) { | |||||
return false; | |||||
} | |||||
// If the viewer has access to only one space, pretend spaces simply don't | |||||
// exist. | |||||
$spaces = self::getViewerSpaces($viewer); | |||||
return (count($spaces) > 1); | |||||
} | |||||
public static function getAllSpaces() { | public static function getAllSpaces() { | ||||
$cache = PhabricatorCaches::getRequestCache(); | $cache = PhabricatorCaches::getRequestCache(); | ||||
$cache_key = self::KEY_ALL; | $cache_key = self::KEY_ALL; | ||||
$spaces = $cache->getKey($cache_key); | $spaces = $cache->getKey($cache_key); | ||||
if ($spaces === null) { | if ($spaces === null) { | ||||
$spaces = id(new PhabricatorSpacesNamespaceQuery()) | $spaces = id(new PhabricatorSpacesNamespaceQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |