serializer = $serializer; $this->baseUri = $base_uri; } /** * {@inheritdoc} */ public function getDefinition($id) { if (!$this->hasDefinition($id)) { throw new LibraryDefinitionNotFoundException($id); } return $this->serializer->decode($this->getSerializedDefinition($id)); } /** * Gets the contents of the library file. * * @param $id * The library ID to retrieve the serialized definition for. * * @return string * The serialized library definition. * * @throws \Drupal\libraries\ExternalLibrary\Exception\LibraryDefinitionNotFoundException */ abstract protected function getSerializedDefinition($id); /** * Returns the file URI of the library definition file for a given library ID. * * @param $id * The ID of the external library. * * @return string * The file URI of the file the library definition resides in. */ protected function getFileUri($id) { $filename = $id . '.' . $this->serializer->getFileExtension(); return "$this->baseUri/$filename"; } }