3 namespace Drupal\libraries\ExternalLibrary\Version;
5 use Drupal\Component\Plugin\Factory\FactoryInterface;
6 use Drupal\libraries\ExternalLibrary\LibraryInterface;
9 * Provides an interface for versioned libraries.
11 * Version detection and negotiation is a key aspect of Libraries API's
12 * functionality so most libraries should implement this interface. In theory,
13 * however, it might be possible for the same library to be available in
14 * multiple versions and, for example, different versions being loaded on
15 * different pages. In this case, a simple getVersion() method, does not make
16 * sense. To support such advanced version detection behavior in the future or
17 * in a separate module, version detection is split into a separate interface.
21 * @todo Support versioned metadata, i.e. different library file names or
22 * locations for different library versions.
24 interface VersionedLibraryInterface extends LibraryInterface {
27 * Gets the version of the library.
30 * The version string, for example 1.0, 2.1.4, or 3.0.0-alpha5.
32 * @throws \Drupal\libraries\ExternalLibrary\Exception\UnknownLibraryVersionException
34 * @see \Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface::setVersion()
36 public function getVersion();
39 * Sets the version of the library.
41 * @param string $version
42 * The version of the library.
46 * @see \Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface::getVersion()
48 public function setVersion($version);
51 * Gets the version detector of this library using the detector factory.
53 * Because determining the installation version of a library is not specific
54 * to any library or even any library type, this logic is offloaded to
55 * separate detector objects.
57 * @param \Drupal\Component\Plugin\Factory\FactoryInterface $detector_factory
59 * @return \Drupal\libraries\ExternalLibrary\Version\VersionDetectorInterface
61 * @see \Drupal\libraries\ExternalLibrary\Version\VersionDetectorInterface
63 public function getVersionDetector(FactoryInterface $detector_factory);