Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepositoryURI.php
| Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | final class PhabricatorRepositoryURI | ||||
| public function isBuiltin() { | public function isBuiltin() { | ||||
| return (bool)$this->getBuiltinProtocol(); | return (bool)$this->getBuiltinProtocol(); | ||||
| } | } | ||||
| public function getEffectiveDisplayType() { | public function getEffectiveDisplayType() { | ||||
| $display = $this->getDisplayType(); | $display = $this->getDisplayType(); | ||||
| if ($display != self::IO_DEFAULT) { | if ($display != self::DISPLAY_DEFAULT) { | ||||
| return $display; | return $display; | ||||
| } | } | ||||
| return $this->getDefaultDisplayType(); | return $this->getDefaultDisplayType(); | ||||
| } | } | ||||
| public function getDefaultDisplayType() { | public function getDefaultDisplayType() { | ||||
| switch ($this->getEffectiveIOType()) { | switch ($this->getEffectiveIOType()) { | ||||
| case self::IO_MIRROR: | case self::IO_MIRROR: | ||||
| case self::IO_OBSERVE: | case self::IO_OBSERVE: | ||||
| return self::DISPLAY_NEVER; | |||||
| case self::IO_NONE: | case self::IO_NONE: | ||||
| if ($this->isBuiltin()) { | |||||
| return self::DISPLAY_NEVER; | return self::DISPLAY_NEVER; | ||||
| } else { | |||||
| return self::DISPLAY_ALWAYS; | |||||
| } | |||||
| case self::IO_READ: | case self::IO_READ: | ||||
| case self::IO_READWRITE: | case self::IO_READWRITE: | ||||
| // By default, only show the "best" version of the builtin URI, not the | // By default, only show the "best" version of the builtin URI, not the | ||||
| // other redundant versions. | // other redundant versions. | ||||
| if ($this->isBuiltin()) { | |||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $other_uris = $repository->getURIs(); | $other_uris = $repository->getURIs(); | ||||
| $identifier_value = array( | $identifier_value = array( | ||||
| self::BUILTIN_IDENTIFIER_CALLSIGN => 3, | self::BUILTIN_IDENTIFIER_CALLSIGN => 3, | ||||
| self::BUILTIN_IDENTIFIER_SHORTNAME => 2, | self::BUILTIN_IDENTIFIER_SHORTNAME => 2, | ||||
| self::BUILTIN_IDENTIFIER_ID => 1, | self::BUILTIN_IDENTIFIER_ID => 1, | ||||
| ); | ); | ||||
| $have_identifiers = array(); | $have_identifiers = array(); | ||||
| foreach ($other_uris as $other_uri) { | foreach ($other_uris as $other_uri) { | ||||
| if ($other_uri->getIsDisabled()) { | if ($other_uri->getIsDisabled()) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $identifier = $other_uri->getBuiltinIdentifier(); | $identifier = $other_uri->getBuiltinIdentifier(); | ||||
| if (!$identifier) { | if (!$identifier) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $have_identifiers[$identifier] = $identifier_value[$identifier]; | $have_identifiers[$identifier] = $identifier_value[$identifier]; | ||||
| } | } | ||||
| $best_identifier = max($have_identifiers); | $best_identifier = max($have_identifiers); | ||||
| $this_identifier = $identifier_value[$this->getBuiltinIdentifier()]; | $this_identifier = $identifier_value[$this->getBuiltinIdentifier()]; | ||||
| if ($this_identifier < $best_identifier) { | if ($this_identifier < $best_identifier) { | ||||
| return self::DISPLAY_NEVER; | return self::DISPLAY_NEVER; | ||||
| } | } | ||||
| } | |||||
| return self::DISPLAY_ALWAYS; | return self::DISPLAY_ALWAYS; | ||||
| } | } | ||||
| return self::DISPLAY_NEVER; | return self::DISPLAY_NEVER; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines | |||||