Chris@17: name = $name; Chris@17: $this->url = $url; Chris@17: Chris@17: try { Chris@17: foreach ($endpoints as $endpoint) { Chris@17: $endpoint += ['formats' => [], 'schemes' => [], 'discovery' => FALSE]; Chris@17: $this->endpoints[] = new Endpoint($endpoint['url'], $this, $endpoint['schemes'], $endpoint['formats'], $endpoint['discovery']); Chris@17: } Chris@17: } Chris@17: catch (\InvalidArgumentException $e) { Chris@17: // Just skip all the invalid endpoints. Chris@17: // @todo Log the exception message to help with debugging in Chris@17: // https://www.drupal.org/project/drupal/issues/2972846. Chris@17: } Chris@17: Chris@17: if (empty($this->endpoints)) { Chris@17: throw new ProviderException('Provider @name does not define any valid endpoints.', $this); Chris@17: } Chris@17: } Chris@17: Chris@17: /** Chris@17: * Returns the provider name. Chris@17: * Chris@17: * @return string Chris@17: * Name of the provider. Chris@17: */ Chris@17: public function getName() { Chris@17: return $this->name; Chris@17: } Chris@17: Chris@17: /** Chris@17: * Returns the provider URL. Chris@17: * Chris@17: * @return string Chris@17: * URL of the provider. Chris@17: */ Chris@17: public function getUrl() { Chris@17: return $this->url; Chris@17: } Chris@17: Chris@17: /** Chris@17: * Returns the provider endpoints. Chris@17: * Chris@17: * @return \Drupal\media\OEmbed\Endpoint[] Chris@17: * List of endpoints this provider exposes. Chris@17: */ Chris@17: public function getEndpoints() { Chris@17: return $this->endpoints; Chris@17: } Chris@17: Chris@17: }