interface VersionedLibraryInterface in Libraries API 8.3
Provides an interface for versioned libraries.
Version detection and negotiation is a key aspect of Libraries API's functionality so most libraries should implement this interface. In theory, however, it might be possible for the same library to be available in multiple versions and, for example, different versions being loaded on different pages. In this case, a simple getVersion() method, does not make sense. To support such advanced version detection behavior in the future or in a separate module, version detection is split into a separate interface.
@todo Support versioned metadata, i.e. different library file names or locations for different library versions.
Hierarchy
- interface \Drupal\libraries\ExternalLibrary\LibraryInterface
- interface \Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface
Expanded class hierarchy of VersionedLibraryInterface
All classes that implement VersionedLibraryInterface
Related topics
8 files declare their use of VersionedLibraryInterface
- AssetLibraryInterface.php in src/
ExternalLibrary/ Asset/ AssetLibraryInterface.php - LibraryBase.php in src/
ExternalLibrary/ LibraryBase.php - LibraryTypeBase.php in src/
ExternalLibrary/ Type/ LibraryTypeBase.php - LinePatternDetector.php in src/
Plugin/ libraries/ VersionDetector/ LinePatternDetector.php - LinePatternDetectorTest.php in tests/
src/ Unit/ Plugin/ libraries/ VersionDetector/ LinePatternDetectorTest.php
File
- src/
ExternalLibrary/ Version/ VersionedLibraryInterface.php, line 24
Namespace
Drupal\libraries\ExternalLibrary\VersionView source
interface VersionedLibraryInterface extends LibraryInterface {
/**
* Gets the version of the library.
*
* @return string
* The version string, for example 1.0, 2.1.4, or 3.0.0-alpha5.
*
* @throws \Drupal\libraries\ExternalLibrary\Exception\UnknownLibraryVersionException
*
* @see \Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface::setVersion()
*/
public function getVersion();
/**
* Sets the version of the library.
*
* @param string $version
* The version of the library.
*
* @reutrn $this
*
* @see \Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface::getVersion()
*/
public function setVersion($version);
/**
* Gets the version detector of this library using the detector factory.
*
* Because determining the installation version of a library is not specific
* to any library or even any library type, this logic is offloaded to
* separate detector objects.
*
* @param \Drupal\Component\Plugin\Factory\FactoryInterface $detector_factory
*
* @return \Drupal\libraries\ExternalLibrary\Version\VersionDetectorInterface
*
* @see \Drupal\libraries\ExternalLibrary\Version\VersionDetectorInterface
*/
public function getVersionDetector(FactoryInterface $detector_factory);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LibraryInterface:: |
public static | function | Creates an instance of the library from its definition. | 1 |
LibraryInterface:: |
public | function | Returns the ID of the library. | |
LibraryInterface:: |
public | function | Returns the library type of the library. | 1 |
VersionedLibraryInterface:: |
public | function | Gets the version of the library. | |
VersionedLibraryInterface:: |
public | function | Gets the version detector of this library using the detector factory. | |
VersionedLibraryInterface:: |
public | function | Sets the version of the library. |