Skip to content

Commit c22e88f

Browse files
committed
Updated docs
1 parent 99e57d3 commit c22e88f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/Plugins/MediaEmbed/Federated_sites.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,26 @@ echo $html;
9999
<iframe data-s9e-mediaembed="xenforo" allowfullscreen="" loading="lazy" onload="let c=new MessageChannel;c.port1.onmessage=e=&gt;this.style.height=e.data+'px';this.contentWindow.postMessage('s9e:init','*',[c.port2])" scrolling="no" style="border:0;height:300px;width:100%" src="https://s9e.github.io/iframe/2/xenforo.min.html#https://xenforo.com/community/threads/217381"></iframe>
100100
```
101101

102-
## Any other sites
102+
103+
## Discoverability
104+
105+
Some of the default sites have a helper class used to configure them. In particular, federated sites offer a `ConfigurableHostInterface` interface that can be used to manipulate the list of allowed instances.
106+
107+
In the example below, we check all of the default sites for the presence of an `helper` attribute in their config and list those whose the actual helper instance implements `ConfigurableHostInterface`. This can be used to discover federated sites in the default sites.
103108

104109
```php
105110
use s9e\TextFormatter\Plugins\MediaEmbed\Configurator\SiteHelpers\ConfigurableHostInterface;
106-
$configurator = new s9e\TextFormatter\Configurator;
107111

108-
// Add whichever sites you like, here we add all the default sites
112+
$configurator = new s9e\TextFormatter\Configurator;
109113
foreach ($configurator->MediaEmbed->defaultSites as $siteId => $siteConfig)
110-
{
111-
$configurator->MediaEmbed->add($siteId);
112-
}
113-
114-
foreach ($configurator->MediaEmbed->getSites() as $siteId => $siteConfig)
115114
{
116115
if (!isset($siteConfig['helper']))
117116
{
118117
continue;
119118
}
120-
if (is_a($siteConfig['helper'], ConfigurableHostInterface::class, true))
119+
120+
$siteHelper = $configurator->MediaEmbed->getSiteHelper($siteId);
121+
if ($siteHelper instanceof ConfigurableHostInterface)
121122
{
122123
echo $siteConfig['name'], " is configurable via getSiteHelper('$siteId')->setHosts()\n";
123124
}

0 commit comments

Comments
 (0)