예제 #1
0
 /**
  * Locates a library.
  *
  * @param \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface $library
  *   The library to locate.
  *
  * @see \Drupal\libraries\ExternalLibrary\Local\LocatorInterface::locate()
  */
 public function locate(LocalLibraryInterface $library)
 {
     /** @var \Drupal\Core\StreamWrapper\LocalStream $stream_wrapper */
     $stream_wrapper = $this->streamWrapperManager->getViaScheme($this->scheme);
     assert('$stream_wrapper instanceof \\Drupal\\Core\\StreamWrapper\\LocalStream');
     // Calling LocalStream::getDirectoryPath() explicitly avoids the realpath()
     // usage in LocalStream::getLocalPath(), which breaks if Libraries API is
     // symbolically linked into the Drupal installation.
     $path = $stream_wrapper->getDirectoryPath() . '/' . $library->getId();
     if (is_dir($path) && is_readable($path)) {
         $library->setLocalPath($path);
     } else {
         $library->setUninstalled();
     }
 }
예제 #2
0
 /**
  * Gets the URI of a library.
  *
  * @param \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface $library
  *   The library.
  *
  * @return string
  *   The URI of the library.
  */
 protected function getUri(LocalLibraryInterface $library)
 {
     return $this->scheme . '://' . $library->getId();
 }