X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Flibraries%2Fsrc%2FExternalLibrary%2FLocal%2FLocalLibraryTrait.php;fp=web%2Fmodules%2Fcontrib%2Flibraries%2Fsrc%2FExternalLibrary%2FLocal%2FLocalLibraryTrait.php;h=3f08e4ba4c1f2d346aa6158f6594e56ea3034cba;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/libraries/src/ExternalLibrary/Local/LocalLibraryTrait.php b/web/modules/contrib/libraries/src/ExternalLibrary/Local/LocalLibraryTrait.php new file mode 100644 index 000000000..3f08e4ba4 --- /dev/null +++ b/web/modules/contrib/libraries/src/ExternalLibrary/Local/LocalLibraryTrait.php @@ -0,0 +1,99 @@ +installed; + } + + /** + * Marks the library as uninstalled. + * + * A corresponding method to mark the library as installed is not provided as + * an installed library should have a library path, so that + * LocalLibraryInterface::setLibraryPath() can be used instead. + * + * @return $this + * + * @see \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface::setUninstalled() + */ + public function setUninstalled() { + $this->installed = FALSE; + return $this; + } + + /** + * Gets the path to the library. + * + * @return string + * The path to the library relative to the app root. + * + * @throws \Drupal\libraries\ExternalLibrary\Exception\LibraryNotInstalledException + * + * @see \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface::getLocalPath() + */ + public function getLocalPath() { + if (!$this->isInstalled()) { + /** @var \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface $this */ + throw new LibraryNotInstalledException($this); + } + + return $this->localPath; + } + + /** + * Sets the library path of the library. + * + * @param string $path + * The path to the library. + * + * @see \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface::getLocalPath() + */ + public function setLocalPath($path) { + $this->installed = TRUE; + $this->localPath = (string) $path; + + assert('$this->localPath !== ""'); + assert('$this->localPath[0] !== "/"'); + } + +}