Source of file OGMusicSong.php
Size: 2,623 Bytes - Last Modified: 2021-12-23T10:55:43+00:00
/var/www/docs.ssmods.com/process/src/src/ObjectBuilders/Music/OGMusicSong.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | <?php namespace TractorCow\OpenGraph\ObjectBuilders\Music; use TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\IOGMusicAlbum; use TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\IOGMusicSong; use TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\Relations\IOGSongAlbum; class OGMusicSong extends AbstractOGMusic { /** * Builds a list of song/album links links * @param string $tags The current tag string to append these two * @param string $namespace The namespace to use for this element * @param IOGSongAlbum[]|IOGSongAlbum|IOGMusicAlbum[]|IOGMusicAlbum|string[]|string $value Related album(s) or link(s) to album(s) */ protected function appendRelatedAlbumList(&$tags, $namespace, $value) { if (empty($value)) { return; } // Handle situation where multiple items are presented if ($this->isValueIterable($value)) { foreach ($value as $album) { $this->appendRelatedAlbumList($tags, $namespace, $album); } return; } // Handle explicit profile object if ($this->implementsType($value, IOGSongAlbum::class)) { /* @var $value IOGSongAlbum */ $this->appendRelatedAlbumList($tags, $namespace, $value->getOGAlbum()); $this->AppendTag($tags, "$namespace:disc", $value->getOGDisc()); $this->AppendTag($tags, "$namespace:track", $value->getOGTrack()); return; } if ($this->implementsType($value, IOGMusicAlbum::class)) { $this->AppendTag($tags, $namespace, $value->AbsoluteLink()); return; } // Handle image URL being given if (is_string($value)) { $this->AppendTag($tags, $namespace, $value); return; } // Fail if could not determine presented value type trigger_error('Invalid album type: ' . gettype($value), E_USER_ERROR); } protected function appendSongTags(&$tags, IOGMusicSong $song) { $this->AppendTag($tags, 'music:duration', $song->getOGMusicDuration()); $this->appendRelatedProfileTags($tags, 'music:musician', $song->getOGMusicMusicians()); $this->appendRelatedAlbumList($tags, 'music:album', $song->getOGMusicAlbums()); } public function BuildTags(&$tags, $object, $config) { parent::BuildTags($tags, $object, $config); $this->appendSongTags($tags, $object); } } |