feat: remove mpratt/embera and it's related implementations

This commit is contained in:
2026-02-03 17:08:59 +01:00
parent 67774ab5aa
commit 9ccafb5e4e
9 changed files with 1 additions and 272 deletions
-1
View File
@@ -22,7 +22,6 @@
"goteo/benzina": "^0.5",
"guzzlehttp/psr7": "^2.8",
"jolicode/automapper": "^9.2",
"mpratt/embera": "~2.0",
"nelmio/cors-bundle": "^2.3",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.24",
Generated
+1 -72
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "19fa0902b062f1449ae15c2d002ede49",
"content-hash": "ae8f53f2074433fb0f88f2c628c53d25",
"packages": [
{
"name": "api-platform/doctrine-common",
@@ -3628,77 +3628,6 @@
],
"time": "2025-03-24T10:02:05+00:00"
},
{
"name": "mpratt/embera",
"version": "2.0.42",
"source": {
"type": "git",
"url": "https://github.com/mpratt/Embera.git",
"reference": "afa728339c6f078c803c9277a5054ca241b3c469"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mpratt/Embera/zipball/afa728339c6f078c803c9277a5054ca241b3c469",
"reference": "afa728339c6f078c803c9277a5054ca241b3c469",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=5.6"
},
"require-dev": {
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.0||^10.0",
"symfony/yaml": "^2.1"
},
"suggest": {
"ext-curl": "Fetch data using curl instead of using file_get_contents"
},
"type": "library",
"autoload": {
"psr-4": {
"Embera\\": "src/Embera"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Pratt",
"email": "yo@michael-pratt.com",
"homepage": "http://www.michael-pratt.com",
"role": "Author/Developer"
}
],
"description": "Oembed consumer library. Converts urls into their html embed code. Supports 150+ sites, such as Youtube, Twitter, vimeo, Instagram etc.",
"homepage": "https://github.com/mpratt/Embera",
"keywords": [
"Auto embed",
"Embed Text",
"Responsive Embeds",
"Url Embed",
"embed",
"instagram",
"oembed",
"twitter",
"vimeo",
"vine",
"youtube"
],
"support": {
"issues": "https://github.com/mpratt/Embera/issues",
"source": "https://github.com/mpratt/Embera/tree/2.0.42"
},
"funding": [
{
"url": "https://paypal.me/mtpratt",
"type": "paypal"
}
],
"time": "2025-01-04T06:07:59+00:00"
},
{
"name": "nelmio/cors-bundle",
"version": "2.5.0",
-9
View File
@@ -22,10 +22,6 @@ services:
tags: ['app.matchfunding.formula']
App\Matchfunding\Rule\RuleInterface:
tags: ['app.matchfunding.rule']
App\Service\Embed\Filter\EmbedFilterInterface:
tags: ['app.embed.embed_filter']
App\Service\Embed\Provider\EmbedProviderFactoryInterface:
tags: ['app.embed.provider_factory']
AutoMapper\Provider\ProviderInterface:
tags: ['app.mapping.map_provider']
AutoMapper\Transformer\PropertyTransformer\PropertyTransformerInterface:
@@ -85,11 +81,6 @@ services:
arguments:
- '%kernel.default_locale%'
App\Service\Embed\Provider\PeertubeEmbedProviderFactory:
bind:
$hosts:
- 'peertube.plataformess.org'
App\State\MoneyTotalStateProvider:
arguments:
- !tagged 'api_platform.doctrine.orm.query_extension.collection'
@@ -1,22 +0,0 @@
<?php
namespace App\Service\Embed\Filter;
interface EmbedFilterInterface
{
/**
* Check for support of the data provider.
*
* @param string $providerUrl The URL of the provider, as given by the Embera Provider
*/
public static function supports(string $providerUrl): bool;
/**
* Apply filter to embed data.
*
* @param array $data The embed data, as given by the Embera Provider
*
* @return array The transformed data array
*/
public static function filter(array $data): array;
}
@@ -1,25 +0,0 @@
<?php
namespace App\Service\Embed\Filter;
class VimeoEmbedFilter implements EmbedFilterInterface
{
public static function supports(string $providerUrl): bool
{
return \str_ends_with($providerUrl, 'vimeo.com');
}
public static function filter(array $data): array
{
if (!\array_key_exists('thumbnail_url', $data)) {
return $data;
}
$lowResPath = \parse_url($data['thumbnail_url'], \PHP_URL_PATH);
$highResPath = \preg_replace('/_\d+x\d+$/', '_900x500', $lowResPath);
$data['thumbnail_url'] = \str_replace($lowResPath, $highResPath, $data['thumbnail_url']);
return $data;
}
}
@@ -1,22 +0,0 @@
<?php
namespace App\Service\Embed\Filter;
class YoutubeEmbedFilter implements EmbedFilterInterface
{
public static function supports(string $providerUrl): bool
{
return \str_ends_with($providerUrl, 'youtube.com');
}
public static function filter(array $data): array
{
if (!\array_key_exists('thumbnail_url', $data)) {
return $data;
}
$data['thumbnail_url'] = \preg_replace('/\w+.jpg$/', 'maxresdefault.jpg', $data['thumbnail_url']);
return $data;
}
}
@@ -1,18 +0,0 @@
<?php
namespace App\Service\Embed\Provider;
use Embera\Provider\ProviderInterface as EmbedProviderInterface;
interface EmbedProviderFactoryInterface
{
/**
* @return array Config for Embera
*/
public function getConfig(): array;
/**
* @return array<string, EmbedProviderInterface>
*/
public function createProviders(): array;
}
@@ -1,63 +0,0 @@
<?php
namespace App\Service\Embed\Provider;
use Embera\Provider\ProviderAdapter as EmbedProvider;
use Embera\Provider\ProviderInterface as EmbedProviderInterface;
use Embera\Url;
/**
* Generic PeerTube provider for Embera that can work for many instance hosts.
*/
class PeertubeEmbedProvider extends EmbedProvider implements EmbedProviderInterface
{
protected $endpoint = '/services/oembed';
protected static $hosts = [];
/**
* Is updated when Embera decides this provider works for the URL when validating it.
*/
private ?string $currentHost = null;
protected $httpsSupport = true;
public function __construct($url, array $config = [])
{
parent::__construct($url, $config);
self::$hosts = $config['peertube_hosts'];
}
public function validateUrl(Url $url): bool
{
foreach (self::$hosts as $host) {
$hostPattern = \sprintf('~%s/w/([^/]+)~i', \preg_quote($host));
if (!\preg_match($hostPattern, (string) $url)) {
continue;
}
$this->currentHost = $host;
return true;
}
return false;
}
public function getEndpoint(): string
{
return \sprintf('https://%s%s', $this->currentHost, $this->endpoint);
}
/** inline {@inheritdoc} */
public function normalizeUrl(Url $url): Url
{
$url->convertToHttps();
$url->removeQueryString();
$url->removeLastSlash();
return $url;
}
}
@@ -1,40 +0,0 @@
<?php
namespace App\Service\Embed\Provider;
use Embera\Provider\ProviderInterface as EmbedProviderInterface;
/**
* Embera expects that each is provider is for one specific host,
* but there are many PeerTube hosts that can be accepted.
*
* This factory creates PeertubeEmbedProviders for each known Peertube instance host.
*/
class PeertubeEmbedProviderFactory implements EmbedProviderFactoryInterface
{
/**
* @param string[] $hosts
*/
public function __construct(
private array $hosts,
) {}
public function getConfig(): array
{
return ['peertube_hosts' => $this->hosts];
}
/**
* @return array<string, EmbedProviderInterface>
*/
public function createProviders(): array
{
$providers = [];
foreach ($this->hosts as $host) {
$providers[$host] = PeertubeEmbedProvider::class;
}
return $providers;
}
}