diff --git a/src/ContextTypes/MusicAbstractContext.php b/src/ContextTypes/MusicAbstractContext.php index f5bd4ea..0096061 100644 --- a/src/ContextTypes/MusicAbstractContext.php +++ b/src/ContextTypes/MusicAbstractContext.php @@ -38,17 +38,26 @@ protected function setGenreAttribute($items) /** * Set artist attribute * - * @param array|string $item + * @param array|string $items * @return array */ - protected function setByArtistAttribute($item) + protected function setByArtistAttribute($items) { - if ( ! is_array($item)) + if ( ! is_array($items)) { - return $item; + return $items; } - return $this->getNestedContext(MusicGroup::class, $item); + //Check if not multidimensional array (for backward compatibility) + if((count($items) == count($items, COUNT_RECURSIVE))) + { + return $this->getNestedContext(MusicGroup::class, $items); + } + + //multiple artists + return array_map(function ($item) { + return $this->getNestedContext(MusicGroup::class, $item); + }, $items); } /** diff --git a/src/ContextTypes/MusicRecording.php b/src/ContextTypes/MusicRecording.php index a093b6d..70a369e 100644 --- a/src/ContextTypes/MusicRecording.php +++ b/src/ContextTypes/MusicRecording.php @@ -26,17 +26,26 @@ class MusicRecording extends MusicAbstractContext /** * Set in album attribute * - * @param array|string $item + * @param array|string $items * @return array */ - protected function setInAlbumAttribute($item) + protected function setInAlbumAttribute($items) { - if ( ! is_array($item)) + if ( ! is_array($items)) { - return $item; + return $items; + } + + //Check if not multidimensional array (for backward compatibility) + if((count($items) == count($items, COUNT_RECURSIVE))) + { + return $this->getNestedContext(MusicAlbum::class, $items); } - return $this->getNestedContext(MusicAlbum::class, $item); + //multiple albums + return array_map(function ($item) { + return $this->getNestedContext(MusicAlbum::class, $item); + }, $items); } /**