Refactor
This commit is contained in:
parent
6689a06e37
commit
b8b2d60275
1 changed files with 21 additions and 26 deletions
47
src/classes/cache/embed.php
vendored
47
src/classes/cache/embed.php
vendored
|
@ -38,40 +38,35 @@ class Embed extends Cache
|
||||||
$info = $this->exists() ? json_decode(file_get_contents($filepath)) : new \stdClass();
|
$info = $this->exists() ? json_decode(file_get_contents($filepath)) : new \stdClass();
|
||||||
|
|
||||||
if (true === $generateCache) {
|
if (true === $generateCache) {
|
||||||
$infoToSave = $info;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* Fetch embed info
|
* Fetch embed info
|
||||||
*
|
*
|
||||||
* @link https://github.com/oscarotero/Embed
|
* @link https://github.com/oscarotero/Embed
|
||||||
*/
|
*/
|
||||||
$embed = new \Embed\Embed();
|
$embed = new \Embed\Embed();
|
||||||
$info = $embed->get($this->url);
|
$embedInfo = $embed->get($this->url);
|
||||||
|
|
||||||
/** Convert embed info to a saveable format (JSON) stdClass */
|
/** Convert embed info to a saveable format (JSON) stdClass */
|
||||||
$infoToSave = new \stdClass();
|
$info->authorName = (string) $embedInfo->authorName;
|
||||||
$infoToSave->authorName = (string) $info->authorName;
|
$info->authorUrl = (string) $embedInfo->authorUrl;
|
||||||
$infoToSave->authorUrl = (string) $info->authorUrl;
|
$info->cms = (string) $embedInfo->cms;
|
||||||
$infoToSave->cms = (string) $info->cms;
|
$info->code = (string) $embedInfo->code;
|
||||||
$infoToSave->code = (string) $info->code;
|
$info->description = (string) $embedInfo->description;
|
||||||
$infoToSave->description = (string) $info->description;
|
$info->favicon = (string) $embedInfo->favicon;
|
||||||
$infoToSave->favicon = (string) $info->favicon;
|
$info->feeds = (array) $embedInfo->feeds;
|
||||||
$infoToSave->feeds = (array) $info->feeds;
|
$info->icon = (string) $embedInfo->icon;
|
||||||
$infoToSave->icon = (string) $info->icon;
|
$info->image = (string) $embedInfo->image;
|
||||||
$infoToSave->image = (string) $info->image;
|
$info->keywords = (array) $embedInfo->keywords;
|
||||||
$infoToSave->keywords = (array) $info->keywords;
|
$info->language = (string) $embedInfo->language;
|
||||||
$infoToSave->language = (string) $info->language;
|
$info->languages = (array) $embedInfo->languages;
|
||||||
$infoToSave->languages = (array) $info->languages;
|
$info->license = (string) $embedInfo->license;
|
||||||
$infoToSave->license = (string) $info->license;
|
$info->providerName = (string) $embedInfo->providerName;
|
||||||
$infoToSave->providerName = (string) $info->providerName;
|
$info->providerUrl = (string) $embedInfo->providerUrl;
|
||||||
$infoToSave->providerUrl = (string) $info->providerUrl;
|
$info->publishedTime = $embedInfo->publishedTime ? $embedInfo->publishedTime->format('d.m.Y') : '';
|
||||||
$infoToSave->publishedTime = $info->publishedTime ? $info->publishedTime->format('d.m.Y') : '';
|
$info->redirect = (string) $embedInfo->redirect;
|
||||||
$infoToSave->redirect = (string) $info->redirect;
|
$info->title = (string) $embedInfo->title;
|
||||||
$infoToSave->title = (string) $info->title;
|
$info->url = (string) $embedInfo->url;
|
||||||
$infoToSave->url = (string) $info->url;
|
|
||||||
|
|
||||||
$info = $infoToSave;
|
|
||||||
} catch (\Throwable $ex) {
|
} catch (\Throwable $ex) {
|
||||||
$generateCache = false;
|
$generateCache = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue