Acast.php
9 months ago
ActBlue.php
9 months ago
Adilo.php
9 months ago
Adways.php
9 months ago
Afreecatv.php
9 months ago
Altium.php
9 months ago
Altru.php
9 months ago
Amtraker.php
9 months ago
Animoto.php
9 months ago
AnnieMusic.php
9 months ago
Apester.php
9 months ago
Archivos.php
9 months ago
Assemblrworld.php
9 months ago
AudioClip.php
9 months ago
Audioboom.php
9 months ago
Audiocom.php
9 months ago
Audiomack.php
9 months ago
Audiomeans.php
9 months ago
BeamsFm.php
9 months ago
BeautifulAI.php
9 months ago
Behance.php
9 months ago
Biqnetwork.php
9 months ago
Bitchute.php
9 months ago
BlackfireIO.php
9 months ago
Blogcast.php
9 months ago
BlueskySocial.php
9 months ago
Bookingmood.php
9 months ago
Bumper.php
9 months ago
Bunny.php
9 months ago
Buttondown.php
9 months ago
Canva.php
9 months ago
Celero.php
9 months ago
Ceros.php
9 months ago
ChartBlocks.php
9 months ago
Chroco.php
9 months ago
CircuitLab.php
9 months ago
Clyp.php
9 months ago
CodeHS.php
9 months ago
CodeSandbox.php
9 months ago
Codepoints.php
9 months ago
Commaful.php
9 months ago
Coub.php
9 months ago
Crumbs.php
9 months ago
Cueup.php
9 months ago
Curated.php
9 months ago
Dadan.php
9 months ago
DailyMotion.php
9 months ago
Dalexni.php
9 months ago
Datawrapper.php
9 months ago
Deseretnews.php
9 months ago
Deviantart.php
9 months ago
Didacte.php
9 months ago
Digiteka.php
9 months ago
DocDroid.php
9 months ago
Docswell.php
9 months ago
DreamBroker.php
9 months ago
EchoesHQ.php
9 months ago
Embedery.php
9 months ago
Ethfiddle.php
9 months ago
EventLive.php
9 months ago
Everviz.php
9 months ago
FITE.php
9 months ago
Facebook.php
9 months ago
Fader.php
9 months ago
FaithLifeTV.php
9 months ago
Figma.php
9 months ago
Fitapp.php
9 months ago
Flickr.php
9 months ago
Flourish.php
9 months ago
FlowHubOrg.php
9 months ago
Fooday.php
9 months ago
Framatube.php
9 months ago
Framer.php
9 months ago
Genially.php
9 months ago
GeographCI.php
9 months ago
GeographUk.php
9 months ago
GetShow.php
9 months ago
GettyImages.php
9 months ago
Giphy.php
9 months ago
GloriaTV.php
9 months ago
Gmetri.php
9 months ago
Gong.php
9 months ago
Grain.php
9 months ago
Gumlet.php
9 months ago
Gyazo.php
9 months ago
Hash.php
9 months ago
Hearthis.php
9 months ago
Heyzine.php
9 months ago
HiHaHo.php
5 years ago
HippoVideo.php
9 months ago
Hopvue.php
9 months ago
Huffduffer.php
9 months ago
IHeartRadio.php
5 years ago
Ideamapper.php
9 months ago
Imgur.php
9 months ago
Infogram.php
9 months ago
Infoveave.php
9 months ago
Injurymap.php
9 months ago
InsightTimer.php
9 months ago
Instagram.php
9 months ago
InsticatorContentEngagementUnit.php
9 months ago
Issuu.php
9 months ago
ItabtechInfosys.php
9 months ago
ItemisCreate.php
9 months ago
Jovian.php
9 months ago
KakaoTV.php
9 months ago
Kickstarter.php
9 months ago
KirimEmail.php
9 months ago
Kit.php
9 months ago
Knacki.php
9 months ago
Kooapp.php
9 months ago
Kurozora.php
9 months ago
LearningApps.php
9 months ago
Libsyn.php
9 months ago
Lineplace.php
9 months ago
Livestream.php
9 months ago
LocalVoicesNetwork.php
9 months ago
Loom.php
9 months ago
LottieFiles.php
9 months ago
Ludus.php
9 months ago
Lumiere.php
9 months ago
Matterport.php
9 months ago
MediaLab.php
9 months ago
Mediastream.php
9 months ago
MedienArchivKuenste.php
9 months ago
MermaidInk.php
9 months ago
Miro.php
9 months ago
MixCloud.php
9 months ago
Mixpanel.php
9 months ago
MusicboxManiacs.php
9 months ago
MySQLVisualExplain.php
9 months ago
NDLA.php
9 months ago
NFTndx.php
9 months ago
Namchey.php
9 months ago
Nanoo.php
9 months ago
NaturalAtlas.php
9 months ago
Nebula.php
9 months ago
NeetoRecord.php
9 months ago
Nfb.php
9 months ago
Odysee.php
9 months ago
OmnyStudio.php
9 months ago
OraTV.php
9 months ago
Orbitvu.php
9 months ago
Origits.php
9 months ago
Outplayed.php
9 months ago
OverflowIO.php
9 months ago
Pandavideo.php
9 months ago
Pastery.php
9 months ago
PeerTubeTV.php
9 months ago
Picturelfy.php
9 months ago
Piggy.php
9 months ago
Pikasso.php
9 months ago
Pinpoll.php
9 months ago
Pinterest.php
9 months ago
Pitchhub.php
9 months ago
Playbuzz.php
9 months ago
Plusdocs.php
9 months ago
Podbean.php
9 months ago
Polldaddy.php
9 months ago
Portfolium.php
9 months ago
Prezi.php
9 months ago
ProviderAdapter.php
5 years ago
ProviderInterface.php
9 months ago
QTpi.php
9 months ago
Quartr.php
9 months ago
RadioPublic.php
5 years ago
Rcvis.php
9 months ago
Reddit.php
9 months ago
ReleaseWire.php
9 months ago
Render.php
9 months ago
Replit.php
9 months ago
ReverbNation.php
9 months ago
RoosterTeeth.php
9 months ago
Rumble.php
9 months ago
RunKit.php
9 months ago
SapoVideos.php
9 months ago
Sbedit.php
9 months ago
Scenes.php
9 months ago
ScreenNine.php
9 months ago
Screencast.php
9 months ago
ScribbleMaps.php
9 months ago
Scribd.php
9 months ago
SendToNews.php
9 months ago
Shoudio.php
9 months ago
ShowTheWay.php
5 years ago
Sketchfab.php
9 months ago
SlateApp.php
9 months ago
Slideshare.php
9 months ago
SmashNotes.php
9 months ago
Smugmug.php
9 months ago
SocialExplorer.php
9 months ago
SongLink.php
9 months ago
SoundCloud.php
9 months ago
SpeakerDeck.php
9 months ago
Spotify.php
9 months ago
Spotlightr.php
9 months ago
Spreaker.php
9 months ago
SproutVideo.php
9 months ago
Spyke.php
9 months ago
StandfordDigitalRepository.php
9 months ago
Streamable.php
9 months ago
Streamio.php
9 months ago
Sudomemo.php
9 months ago
Sutori.php
9 months ago
Sway.php
9 months ago
Synthesia.php
9 months ago
Ted.php
9 months ago
TheNewYorkTimes.php
9 months ago
ThreeQ.php
9 months ago
Tickcounter.php
9 months ago
TikTok.php
9 months ago
TonicAudio.php
9 months ago
Toornament.php
9 months ago
Trackspace.php
9 months ago
TrinityAudio.php
9 months ago
Tumblr.php
9 months ago
Tuxx.php
9 months ago
Tvcf.php
9 months ago
Twinmotion.php
9 months ago
Twitter.php
9 months ago
UAPod.php
9 months ago
UniversitePantheonSorbonne.php
9 months ago
UpecPod.php
9 months ago
UstreamTV.php
9 months ago
Ustudio.php
9 months ago
Verse.php
9 months ago
VidMount.php
9 months ago
Videfit.php
9 months ago
Vidyard.php
9 months ago
Vimeo.php
9 months ago
Viostream.php
9 months ago
Viously.php
9 months ago
Vizdom.php
9 months ago
Vlipsy.php
9 months ago
VouchFor.php
9 months ago
VoxSnap.php
9 months ago
WaveVideo.php
9 months ago
Web3IsGoingJustGreat.php
9 months ago
Webcrumbs.php
9 months ago
Wecandeo.php
9 months ago
Whimsical.php
9 months ago
Wistia.php
9 months ago
Wizer.php
9 months ago
Wokwi.php
9 months ago
WolframCloud.php
9 months ago
Wordpress.php
9 months ago
Wordwall.php
9 months ago
Youtube.php
9 months ago
Yumpu.php
9 months ago
Zeplin.php
9 months ago
Zingsoft.php
9 months ago
Zoomable.php
9 months ago
iFixit.php
9 months ago
ProviderAdapter.php
148 lines
| 1 | <?php |
| 2 | /** |
| 3 | * ProviderAdapter.php |
| 4 | * |
| 5 | * @package Adapters |
| 6 | * @author Michael Pratt <yo@michael-pratt.com> |
| 7 | * @link http://www.michael-pratt.com/ |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | namespace Embera\Provider; |
| 14 | |
| 15 | use Embera\Url; |
| 16 | |
| 17 | /** |
| 18 | * ProviderAdapter has boilerplate methods that help remove code |
| 19 | * from the other providers. It has the basic boilerplate to instantiate |
| 20 | * and validate Providers. |
| 21 | */ |
| 22 | abstract class ProviderAdapter |
| 23 | { |
| 24 | /** @var bool $shouldSendRequest It determins wether we should send api request to get the embed data or we will create embed data manually */ |
| 25 | protected $shouldSendRequest = true; |
| 26 | /** @var Url */ |
| 27 | protected $url; |
| 28 | |
| 29 | /** @var array with hosts where the provider belongs */ |
| 30 | protected static $hosts = []; |
| 31 | |
| 32 | /** @var array Associative array with config/parameters to be sent to the oembed provider */ |
| 33 | protected $config = []; |
| 34 | |
| 35 | /** @var array Array with allowed params for the current Provider */ |
| 36 | protected $allowedParams = [ 'maxwidth', 'maxheight' ]; |
| 37 | |
| 38 | /** @var string The api url for the current service */ |
| 39 | protected $endpoint = null; |
| 40 | |
| 41 | /** @var bool Wether the provider supports https */ |
| 42 | protected $httpsSupport = false; |
| 43 | |
| 44 | /** @var bool Wether the provider supports responsive embeds */ |
| 45 | protected $responsiveSupport = false; |
| 46 | |
| 47 | /** inline {@inheritdoc} */ |
| 48 | public function __construct($url, array $config = []) |
| 49 | { |
| 50 | $this->config = $config; |
| 51 | $this->url = $this->normalizeUrl(new Url($url)); |
| 52 | } |
| 53 | |
| 54 | /** inline {@inheritdoc} */ |
| 55 | public function getParams() |
| 56 | { |
| 57 | $params = []; |
| 58 | foreach ($this->allowedParams as $key) { |
| 59 | if (isset($this->config[$key])) { |
| 60 | $params[$key] = $this->config[$key]; |
| 61 | } |
| 62 | |
| 63 | $customKey = strtolower($this->getProviderName() . '_' . $key); |
| 64 | if (isset($this->config[$customKey])) { |
| 65 | $params[$key] = $this->config[$customKey]; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return array_filter(array_merge($params,[ |
| 70 | 'url' => $this->getUrl(), |
| 71 | ])); |
| 72 | } |
| 73 | |
| 74 | /** inline {@inheritdoc} */ |
| 75 | public function getProviderName() |
| 76 | { |
| 77 | return basename(str_replace('\\', '/', get_class($this))); |
| 78 | } |
| 79 | |
| 80 | /** inline {@inheritdoc} */ |
| 81 | public function getEndpoint() |
| 82 | { |
| 83 | return (string) $this->endpoint; |
| 84 | } |
| 85 | |
| 86 | /** inline {@inheritdoc} */ |
| 87 | public function getUrl($asString = true) |
| 88 | { |
| 89 | if ($asString) { |
| 90 | return $this->url->__toString(); |
| 91 | } |
| 92 | |
| 93 | return $this->url; |
| 94 | } |
| 95 | |
| 96 | /** inline {@inheritdoc} */ |
| 97 | public function hasHttpsSupport() |
| 98 | { |
| 99 | return (bool) $this->httpsSupport; |
| 100 | } |
| 101 | |
| 102 | /** inline {@inheritdoc} */ |
| 103 | public function hasResponsiveSupport() |
| 104 | { |
| 105 | return (bool) $this->responsiveSupport; |
| 106 | } |
| 107 | |
| 108 | /** inline {@inheritdoc} */ |
| 109 | public function modifyResponse(array $response = []) |
| 110 | { |
| 111 | return $response; |
| 112 | } |
| 113 | |
| 114 | /** inline {@inheritdoc} */ |
| 115 | public function getFakeResponse() |
| 116 | { |
| 117 | return array(); |
| 118 | } |
| 119 | |
| 120 | /** inline {@inheritdoc} */ |
| 121 | public function normalizeUrl(Url $url) |
| 122 | { |
| 123 | return $url; |
| 124 | } |
| 125 | |
| 126 | /** inline {@inheritdoc} */ |
| 127 | public static function getHosts() |
| 128 | { |
| 129 | return static::$hosts; |
| 130 | } |
| 131 | |
| 132 | /** inline {@inheritdoc} */ |
| 133 | public static function addHost($host) |
| 134 | { |
| 135 | static::$hosts[] = $host; |
| 136 | } |
| 137 | |
| 138 | /** inline {@inheritdoc} */ |
| 139 | public function shouldSendRequest() |
| 140 | { |
| 141 | return (bool) $this->shouldSendRequest; |
| 142 | } |
| 143 | /** inline {@inheritdoc} */ |
| 144 | public function getStaticResponse() { |
| 145 | return []; |
| 146 | } |
| 147 | } |
| 148 |