public function SessionStreamWrapper::url_stat in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::url_stat()
Return value
array
Overrides PhpStreamWrapperInterface::url_stat
File
- stream_wrapper_example/
src/ StreamWrapper/ SessionStreamWrapper.php, line 741
Class
- SessionStreamWrapper
- Example stream wrapper class to handle session:// streams.
Namespace
Drupal\stream_wrapper_example\StreamWrapperCode
public function url_stat($uri, $flags) {
// @codingStandardsIgnoreEnd
$path = $this
->getLocalPath($uri);
if (!$this->sessionHelper
->checkPath($path)) {
return FALSE;
// No file.
}
// Default to fail.
$return = FALSE;
$mode = 0;
$key = $this->sessionHelper
->getPath($path);
// We will call an array a directory and the root is always an array.
if (is_array($key)) {
// S_IFDIR means it's a directory.
$mode = 040000;
}
elseif ($key !== FALSE) {
// S_IFREG, means it's a file.
$mode = 0100000;
}
if ($mode) {
$size = 0;
if ($mode == 0100000) {
$size = strlen($key);
}
// There are no protections on this, so all writable.
$mode |= 0777;
$return = [
'dev' => 0,
'ino' => 0,
'mode' => $mode,
'nlink' => 0,
'uid' => 0,
'gid' => 0,
'rdev' => 0,
'size' => $size,
'atime' => 0,
'mtime' => 0,
'ctime' => 0,
'blksize' => 0,
'blocks' => 0,
];
}
return $return;
}