You are here

public static function AmpSocialPost::getId in Accelerated Mobile Pages (AMP) 8.3

Get the provider id from an url.

Parameters

$url: The url.

Return value

string The id.

2 calls to AmpSocialPost::getId()
AmpSocialPost::preRenderSocialPost in src/Element/AmpSocialPost.php
Pre-render callback.
AmpSocialPostTest::testGetId in tests/src/Unit/AmpSocialPostTest.php
@covers ::getId @dataProvider idData

File

src/Element/AmpSocialPost.php, line 191

Class

AmpSocialPost
Provides AMP social post elements.

Namespace

Drupal\amp\Element

Code

public static function getId($url, $provider) {
  $patterns = static::getPatterns();
  foreach ($patterns[$provider] as $pattern) {
    if (preg_match($pattern, $url, $matches)) {
      return $matches['id'];
    }
  }
  return FALSE;
}