/** * Change current Session Handler * * @param string|Next\Session\Handlers\Handler $handler * Handler Object or Handler Name * * @throws Next\Session\Handlers\HandlerException * Changing Session Handler to a invalid Handler, characterized as * instance of Next\Session\Hndlers\Handler */ public function changeHandler($handler) { // If we don't have a true Handler... if (!$handler instanceof Handler) { // ... let's find an assigned Handler that matches given string $test = $this->handlers->find($handler); // Nothing Found? if (!$test instanceof Handler) { throw HandlersException::unknownHandler((string) $handler); } // Yeah! We're ninjas! $handler = $test; } // Committing Session $this->session->commit(); // Setting Session Options with Handler Options if (isset($handler->getOptions->savePath)) { $this->session->setSessionSavePath($handler->getOptions->savePath); } $lifetime = isset($handler->getOptions->lifetime) ? $handler->getOptions->lifetime : 0; if ($lifetime > 0) { $this->session->setSessionLifetime($lifetime); } // Changing current Session Handler $this->handler =& $handler; // Restarting Session $this->session->init($this->session->getSessionName(), $this->session->getSessionID()); }
/** * Check Object acceptance * * @param Next\Components\Object $object * Object to test before add to Collection * * @return boolean * TRUE if given Object is not present in Set Collection and FALSE otherwise * * @throws Next\Components\Decorators\DecoratorException * Given decorator is not acceptable in Decorators Chain */ protected function accept(Object $object) { if (parent::accept($object)) { if (!$object instanceof Decorator) { throw DecoratorException::invalidDecorator($object); } return TRUE; } return FALSE; }