public function engine($class = null, array $options = [])
{
if ($class instanceof SessionHandlerInterface) {
return $this->_engine = $class;
}
if ($class === null) {
return $this->_engine;
}
$className = App::className($class, 'Network/Session');
if (!$className) {
throw new InvalidArgumentException(sprintf('The class "%s" does not exist and cannot be used as a session engine', $class));
}
$handler = new $className($options);
if (!$handler instanceof SessionHandlerInterface) {
throw new InvalidArgumentException('The chosen SessionHandler does not implement SessionHandlerInterface, it cannot be used as an engine.');
}
return $this->_engine = $handler;
}