You are here

public function SessionStreamWrapper::mkdir in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::mkdir()

Support for mkdir().

Parameters

string $uri: A string containing the URI to the directory to create.

int $mode: Permission flags - see mkdir().

int $options: A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.

Return value

bool TRUE if directory was successfully created.

Overrides PhpStreamWrapperInterface::mkdir

See also

http://php.net/manual/en/streamwrapper.mkdir.php

File

modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php, line 687

Class

SessionStreamWrapper
Example stream wrapper class to handle session:// streams.

Namespace

Drupal\stream_wrapper_example\StreamWrapper

Code

public function mkdir($uri, $mode, $options) {

  // If this already exists, then we can't mkdir.
  if (is_dir($uri) || is_file($uri)) {
    return FALSE;
  }
  $path = $this
    ->getLocalPath($uri);
  $new_dir = [
    'isadir.txt' => TRUE,
  ];
  $this->sessionHelper
    ->setPath($path, $new_dir);
  return TRUE;
}