[BandcampDailyBridge] Fix list duplicates (#2795)

This commit is contained in:
Yaman Qalieh 2022-06-08 19:37:06 -04:00 committed by GitHub
parent 75c4c9f256
commit 037d5866ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 14 deletions

View File

@ -7,7 +7,7 @@ class BandcampDailyBridge extends BridgeAbstract {
const PARAMETERS = array( const PARAMETERS = array(
'Latest articles' => array(), 'Latest articles' => array(),
'Best of' => array( 'Best of' => array(
'content' => array( 'best-content' => array(
'name' => 'content', 'name' => 'content',
'type' => 'list', 'type' => 'list',
'values' => array( 'values' => array(
@ -28,7 +28,7 @@ class BandcampDailyBridge extends BridgeAbstract {
), ),
), ),
'Genres' => array( 'Genres' => array(
'content' => array( 'genres-content' => array(
'name' => 'content', 'name' => 'content',
'type' => 'list', 'type' => 'list',
'values' => array( 'values' => array(
@ -62,7 +62,7 @@ class BandcampDailyBridge extends BridgeAbstract {
), ),
), ),
'Franchises' => array( 'Franchises' => array(
'content' => array( 'franchises-content' => array(
'name' => 'content', 'name' => 'content',
'type' => 'list', 'type' => 'list',
'values' => array( 'values' => array(
@ -133,23 +133,28 @@ class BandcampDailyBridge extends BridgeAbstract {
case 'Best of': case 'Best of':
case 'Genres': case 'Genres':
case 'Franchises': case 'Franchises':
return self::URI . '/' . $this->getInput('content'); // TODO Switch to array_key_first once php >= 7.3
$contentKey = key(self::PARAMETERS[$this->queriedContext]);
return self::URI . '/' . $this->getInput($contentKey);
default: default:
return parent::getURI(); return parent::getURI();
} }
} }
public function getName() { public function getName() {
if ($this->queriedContext === 'Latest articles') { switch($this->queriedContext) {
case 'Latest articles':
return $this->queriedContext . ' - Bandcamp Daily'; return $this->queriedContext . ' - Bandcamp Daily';
} case 'Best of':
case 'Genres':
if (!is_null($this->getInput('content'))) { case 'Franchises':
$contentValues = array_flip(self::PARAMETERS[$this->queriedContext]['content']['values']); // TODO Switch to array_key_first once php >= 7.3
$contentKey = key(self::PARAMETERS[$this->queriedContext]);
return $contentValues[$this->getInput('content')] . ' - Bandcamp Daily'; $contentValues = array_flip(self::PARAMETERS[$this->queriedContext][$contentKey]['values']);
}
return $contentValues[$this->getInput($contentKey)] . ' - Bandcamp Daily';
default:
return parent::getName(); return parent::getName();
} }
}
} }