Skip to content

Commit

Permalink
Multiple albums in MusicRecording
Browse files Browse the repository at this point in the history
  • Loading branch information
nokimaro authored Jun 15, 2017
1 parent 42336c9 commit 52d6004
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/ContextTypes/MusicRecording.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 52d6004

Please sign in to comment.