/**
  * Check whether stream was already loaded, otherwise fetch from backend
  * and cache it.
  *
  * Multivalued properties have a special handling since the backend returns
  * all streams in a single call.
  *
  * Always checks if the current session is still alive.
  *
  * @throws LogicException when trying to use a stream from a closed session
  *      and on trying to access a nonexisting multivalue id.
  *
  * @return void
  */
 private function init_stream()
 {
     if (null === $this->stream) {
         if ($this->session && !$this->session->isLive()) {
             throw new LogicException("Trying to read a stream from a closed transport.");
         }
         $url = parse_url($this->path);
         $this->session = Session::getSessionFromRegistry($url['host']);
         $property_path = $url['path'];
         $token = isset($url['user']) ? $url['user'] : null;
         if (null === $token) {
             $this->stream = $this->session->getObjectManager()->getBinaryStream($property_path);
         } else {
             // check if streams have been loaded for multivalued properties
             if (!isset(self::$multiValueMap[$token])) {
                 self::$multiValueMap[$token] = $this->session->getObjectManager()->getBinaryStream($property_path);
             }
             $index = isset($url['port']) ? $url['port'] - 1 : 0;
             if (!isset(self::$multiValueMap[$token][$index])) {
                 throw new LogicException("Trying to read a stream from a non existant token '{$token}' or token index '{$index}'.");
             }
             $this->stream = self::$multiValueMap[$token][$index];
         }
     }
 }