Endpoint example

public function __construct($name$url, array $endpoints) {
    $this->name = $name;

    if (!UrlHelper::isValid($url, TRUE) || !UrlHelper::isExternal($url)) {
      throw new ProviderException('Provider @name does not define a valid external URL.', $this);
    }
    $this->url = $url;

    try {
      foreach ($endpoints as $endpoint) {
        $endpoint += ['formats' => [], 'schemes' => [], 'discovery' => FALSE];
        $this->endpoints[] = new Endpoint($endpoint['url']$this$endpoint['schemes']$endpoint['formats']$endpoint['discovery']);
      }
    }
    catch (\InvalidArgumentException $e) {
      // Just skip all the invalid endpoints.       // @todo Log the exception message to help with debugging in       // https://www.drupal.org/project/drupal/issues/2972846.     }

    if (empty($this->endpoints)) {
      throw new ProviderException('Provider @name does not define any valid endpoints.', $this);
    }
  }
/** * @coversDefaultClass \Drupal\media\OEmbed\Endpoint * * @group media */
class EndpointTest extends UnitTestCase {

  /** * @covers ::matchUrl */
  public function testMatchUrl(): void {
    $endpoint = new Endpoint(
      'https://www.youtube.com/oembed',
      $this->createMock('\Drupal\media\OEmbed\Provider'),
      ['https://*.youtube.com/playlist?list=*']
    );
    $this->assertTrue($endpoint->matchUrl('https://www.youtube.com/playlist?list=aBc-EzAs123'));
  }

  /** * @covers ::matchUrl */
  public function testCaseSensitiveMatch(): void {
    
Home | Imprint | This part of the site doesn't use cookies.