本文整理汇总了PHP中PHPCR\SessionInterface::isLive方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionInterface::isLive方法的具体用法?PHP SessionInterface::isLive怎么用?PHP SessionInterface::isLive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPCR\SessionInterface
的用法示例。
在下文中一共展示了SessionInterface::isLive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init_stream
/**
* 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];
}
}
}