LibraryStream.php in System stream wrapper 8
File
src/StreamWrapper/LibraryStream.php
View source
<?php
namespace Drupal\system_stream_wrapper\StreamWrapper;
use Drupal\system_stream_wrapper\Extension\LibraryDiscovery;
class LibraryStream extends ExtensionStreamBase {
protected $drupalRoot;
protected function getOwnerName() {
$name = parent::getOwnerName();
$library_discovery = new LibraryDiscovery($this
->getDrupalRoot());
$files = $library_discovery
->scan(LibraryDiscovery::EXTENSION_TYPE);
if (!isset($files[$name])) {
throw new \InvalidArgumentException("Library {$name} does not exist");
}
return $name;
}
protected function getDirectoryPath() {
$library_discovery = new LibraryDiscovery($this
->getDrupalRoot());
$files = $library_discovery
->scan(LibraryDiscovery::EXTENSION_TYPE);
$name = $this
->getOwnerName();
return $files[$name]
->getPathname();
}
public function getName() {
return $this
->t('Library files');
}
public function getDescription() {
return $this
->t('Local files stored under the libraries directory.');
}
protected function getDrupalRoot() {
if (!isset($this->drupalRoot)) {
$this->drupalRoot = \Drupal::root();
}
return $this->drupalRoot;
}
public function setDrupalRoot($drupalRoot) {
$this->drupalRoot = $drupalRoot;
}
}
Classes
Name |
Description |
LibraryStream |
Defines the read-only library:// stream wrapper for library files. |