You are here

public function SessionHelper::getPath in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/stream_wrapper_example/src/SessionHelper.php \Drupal\stream_wrapper_example\SessionHelper::getPath()

Get a path.

Parameters

string $path: A URI with the SCHEME:// part removed.

Return value

mixed Return the stored value at this "node" of the store.

File

stream_wrapper_example/src/SessionHelper.php, line 173

Class

SessionHelper
Helper to manage file wrapper data stored in the session object.

Namespace

Drupal\stream_wrapper_example

Code

public function getPath($path) {
  $path_info = $this
    ->getParentPath($path);
  $store_info = $this
    ->processPath($path_info['dirname']);
  $leaf = $path_info['basename'];
  if ($store_info === FALSE) {
    return NULL;
  }
  if ($store_info['store'] === $store_info['tip']) {

    // We are at the top of the hierarchy; return the store itself.
    if (empty($path_info['basename'])) {
      return $store_info['store'];
    }
    if (!isset($store_info['store'][$leaf])) {
      return NULL;
    }
  }
  return $store_info['tip'][$leaf];
}