a-blog cms PHP API Reference

Embed extends Facade
in package

埋め込み(oEmbed / OGP)情報の取得サービス。

どのサービスの埋め込みを解決できるかは embed.providers(ProviderRegistry)が 持つ。拡張アプリがサービスを追加する場合は、このファサードではなく Application::make('embed.providers') を ServiceProvider::init() で取得して登録する。

Why not: config/app.php の aliases(グローバル class_alias)へ登録しないのは、 ライブラリ側のグローバルクラス \Embed\Embed と紛らわしく、テンプレートやユーザー拡張で 誤用されやすいため。完全修飾名か別名インポートで参照する(\Field ファサードと同じ扱い)。

Table of Contents

Properties

$container  : Container
$instance  : mixed
$resolvedFacades  : mixed
alias → 解決済みファサードクラス名の逆引き表。

Methods

__callStatic()  : mixed
clearInstance()  : void
テスト用: ファサードがキャッシュしている解決済みインスタンスを破棄する。
fetch()  : EmbedData
fetchWithoutCache()  : EmbedData
fetchWithRetryOnEmptyCache()  : EmbedData
forget()  : void
getInstance()  : mixed
get service instance
isResolvableUrl()  : bool
sanitizeEmbedHtml()  : string
sanitizeForPreview()  : string
setContainer()  : void
swap()  : void
テスト用: サービスインスタンスをスタブ等へ差し替える。
getServiceAlias()  : string
getServiceInstance()  : mixed
isCache()  : bool

Properties

$instance

protected static mixed $instance

$resolvedFacades

alias → 解決済みファサードクラス名の逆引き表。

protected static mixed $resolvedFacades = []

どのサブクラスも再宣言していないため、全ファサード共通で Facade 基底の 1 テーブルを共有する。bind 変更時にどのファサードの static $instance を 破棄すべきか特定するのに使う。値は class-string => true の連想配列にして 重複登録を自然に排除する。

Methods

__callStatic()

public static __callStatic(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
$method : string
$arguments : array<string|int, mixed>

clearInstance()

テスト用: ファサードがキャッシュしている解決済みインスタンスを破棄する。

public static clearInstance() : void

isCache() が true のファサードは解決済みインスタンスを静的プロパティ $instance に 保持するため、コンテナ側だけを差し替えても反映されない。本メソッドでキャッシュを 無効化し、次回アクセスでコンテナから再解決させる。

fetch()

public static fetch(string $url) : EmbedData

キャッシュ経由でメタ情報を取得

Parameters
$url : string
Return values
EmbedData

fetchWithoutCache()

public static fetchWithoutCache(string $url) : EmbedData

キャッシュを使わず取得

Parameters
$url : string
Return values
EmbedData

fetchWithRetryOnEmptyCache()

public static fetchWithRetryOnEmptyCache(string $url) : EmbedData

空キャッシュ(前回取得失敗)のときだけ再取得する

Parameters
$url : string
Return values
EmbedData

forget()

public static forget(string $url) : void

指定URLのキャッシュを破棄

Parameters
$url : string

getInstance()

get service instance

public static getInstance() : mixed

isResolvableUrl()

public static isResolvableUrl(string $url) : bool

埋め込みの取得対象として受け付けるURLか判定

Parameters
$url : string
Return values
bool

sanitizeEmbedHtml()

public static sanitizeEmbedHtml(string $html[, string $title = = '\'\'' ][, string $providerName = = '\'\'' ]) : string

埋め込みHTMLを保存してよい形に確定

Parameters
$html : string
$title : string = = '\'\''
$providerName : string = = '\'\''
Return values
string

sanitizeForPreview()

public static sanitizeForPreview(string $html[, string $title = = '\'\'' ][, string $providerName = = '\'\'' ]) : string

保存済みの埋め込みHTMLをプレビューで実行してよい形に確定

Parameters
$html : string
$title : string = = '\'\''
$providerName : string = = '\'\''
Return values
string

swap()

テスト用: サービスインスタンスをスタブ等へ差し替える。

public static swap(object $instance) : void

DI コンテナのエイリアスを差し替えたうえで、ファサードがキャッシュしている解決済み インスタンス(isCache() が true の場合)を破棄し、次回アクセス時に差し替え後の インスタンスを再解決させる。テスト後は元のインスタンスを渡して再度呼び出し復元する。

Parameters
$instance : object

getServiceAlias()

protected static getServiceAlias() : string
Return values
string

getServiceInstance()

protected static getServiceInstance(string $alias) : mixed
Parameters
$alias : string

isCache()

protected static isCache() : bool
Return values
bool

        
On this page

Search results