Returns specified session section.
public getSection ( $section, $class = SessionSection::class ) : |
||
return |
/** * @return AjaxFileUploaderControl */ public function invoke($basePath) { $control = new AjaxFileUploaderControl($this->ajaxDir, $basePath . $this->getRelativeAjaxPath(), $this->session->getSection('ajaxFileUploader')); $control->onFileUpload[] = $this->handleFileUpload; $control->onAfterFileUpload[] = $this->handleFileUploadUnlink; return $control; }
/** * Sets debug mode. * @param boolean $debugMode */ public function setDebugMode($debugMode) { $this->debugMode = $debugMode; if ($debugMode === true) { $this->sessionStorage = $this->session->getSection(Gettext::$namespace); } }
/** * @param $section * @return Mesour\Components\Session\ISessionSection * @throws Mesour\InvalidArgumentException */ public function getSection($section) { if (!Mesour\Components\Utils\Helpers::validateKeyName($section)) { throw new Mesour\InvalidArgumentException('SessionSection name must be integer or string, ' . gettype($section) . ' given.'); } $this->sections[$section] = $section; return new SessionSection($this->session->getSection($section)); }
/** * Get web passage uri from session if any * @return mixed */ public function getPassage($size = NULL, $include_host = TRUE) { $url = $this->request->url->scheme . '://' . $this->request->url->host; $passage = $this->session->getSection('web_passage')->web_passage ?: []; if ($size) { $passage = array_slice($passage, 0, $size); } if (!$include_host) { $passage = array_map(function ($item) use($url) { return str_replace($url, '', $item); }, $passage); } return $passage; }
/** * @param \Nette\ComponentModel\IContainer $ajaxDir * @param string $ajaxPath * @param \Nette\Http\Session $session */ public function __construct($ajaxDir, $ajaxPath, Session $session) { parent::__construct(); $this->ajaxDir = $ajaxDir; $this->ajaxPath = $ajaxPath; $this->sessionSection = $session->getSection('ajaxUploader-' . $this->getName()); }
public function __construct(EntityManager $entityManager, Session $session, AdministrationManager $administrationManager) { $this->roleRepository = $entityManager->getRepository(Role::class); $this->permissionRepository = $entityManager->getRepository(Permission::class); $this->session = $session->getSection(self::SESSION_SECTION); $this->administrationManager = $administrationManager; }
/** * @param PresenterFactory $presenterFactory * @param BaseRepository $roleRepository * @param Session $session */ public function __construct(PresenterFactory $presenterFactory, BaseRepository $roleRepository, Session $session, Callback $checkConnection) { $this->presenterFactory = $presenterFactory; $this->roleRepository = $roleRepository; $this->session = $session->getSection(self::SESSION_SECTION); $this->checkConnection = $checkConnection; }
/** * @param string * @return Nette\Http\Session|Nette\Http\SessionSection */ public function getSession($namespace = NULL) { if (!$this->session) { throw new Nette\InvalidStateException('Service Session has not been set.'); } return $namespace === NULL ? $this->session : $this->session->getSection($namespace); }
/** * Returns session namespace provided to pass temporary data between redirects. * @return Nette\Http\SessionSection */ public function getFlashSession() { if (empty($this->params[self::FLASH_KEY])) { $this->params[self::FLASH_KEY] = Nette\Utils\Strings::random(4); } return $this->session->getSection('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]); }
/** * @return \Nette\Http\SessionSection */ protected function getStateSession() { if (is_null($this->session)) { throw new \Nette\InvalidStateException('Session is not set! Use \'setSession\' to set session!'); } return $this->session->getSection('VisualPaginator/' . $this->lookupPath('Nette\\ComponentModel\\IComponent', FALSE) ?: $this->getName() . '/states'); }
/** * @throws AuthenticationException * @param array $credentials * @return Identity */ public function authenticate(array $credentials) { list($code, $state) = $credentials; $session = $this->session->getSection(AuthPresenterTrait::$OAUTH_SESSION); if (empty($session->state) || $session->state !== $state) { throw new AuthenticationException('Invalid state.'); } try { $accessToken = $this->provider->getAccessToken('authorization_code', ['code' => $code]); /* @var $data AngelcamUser */ $data = $this->provider->getResourceOwner($accessToken); } catch (\Exception $e) { $invalidToken = $e instanceof ClientException && $e->getResponse()->getStatusCode() === 401; throw new AuthenticationException($invalidToken ? 'Invalid token' : 'Authentication failed', 0, $e); } return new Identity($data->getId(), $data, $accessToken); }
public function __construct(Kdyby\Doctrine\EntityManager $em, Zax\Utils\AppDir $appDir, Nette\Http\Session $session) { $this->em = $em; $this->schemaTool = new Doctrine\ORM\Tools\SchemaTool($this->em); $cacheStorage = new Nette\Caching\Storages\FileStorage($appDir . '/modules/Install/components/Install/installSchema'); $this->cache = new Nette\Caching\Cache($cacheStorage); $this->sessionSection = $session->getSection('ZaxCMS.DatabaseGenerator'); }
public function __construct(\Nette\Http\Session $session, \Fabian\Linkedin\Configuration $config) { $this->session = $session->getSection('linkedin'); if (isset($this->session->access_token)) { $this->accessToken = $this->session->access_token; } $this->config = $config; }
/** * Get security token * @return string */ public function getSecurityToken() { $session = $this->session->getSection(__CLASS__ . '-' . __METHOD__); if (empty($session->securityToken)) { $session->securityToken = md5(uniqid(mt_rand(), true)); } return $session->securityToken; }
public function __construct(EntityManager $entityManager, Session $session, IBrowserControlFactory $browserFactory) { parent::__construct(); $this->entityManager = $entityManager; $this->fileRepository = $entityManager->getRepository(File::class); $this->dirRepository = $entityManager->getRepository(Dir::class); $this->session = $session->getSection('Venne.Content.filesSide'); $this->browserFactory = $browserFactory; }
public function setOldSessId() { $id = $this->session->getSection('voteId'); if (empty($id->id)) { $this->oldId = false; } else { $this->oldId = $id->id; } }
public function __construct(Nette\Http\Session $session, Nette\Caching\IStorage $cacheStorage, Nette\Http\Response $httpResponse) { $this->sessionStorage = $sessionStorage = $session->getSection(self::$namespace); $this->cache = new Nette\Caching\Cache($cacheStorage, self::$namespace); $this->httpResponse = $httpResponse; if (!isset($sessionStorage->newStrings) || !is_array($sessionStorage->newStrings)) { $sessionStorage->newStrings = array(); } }
/** * Loads request from session. * @param string $key * @return Request */ public function loadRequest($key) { $session = $this->session->getSection(self::SESSION_SECTION); if (!isset($session[$key])) { return; } // Cloning is necessary to prevent the stored request from being modified too. $request = clone $session[$key]; if ($this->loader) { try { $this->loader->filterIn($request); } catch (BadRequestException $e) { return; } } $request->setFlag(Request::RESTORED, true); return $request; }
private function completeAuthorizationRequest() { $this->session->getSection(OAuth2Presenter::SESSION_NAMESPACE)->remove(); $response = $this->createResponse(); try { $this->onResponse($this->authorizationServer->completeAuthorizationRequest($this->authorizationRequest, $response)); } catch (AbortException $e) { throw $e; } catch (OAuthServerException $e) { $this->onResponse($e->generateHttpResponse($response)); } catch (\Exception $e) { if ($this->logger) { $this->logger->error($e->getMessage(), ['exception' => $e]); } $body = $this->createStream(); $body->write('Unknown error'); $this->onResponse($response->withStatus(HttpResponse::S500_INTERNAL_SERVER_ERROR)->withBody($body)); } }
/** * @param Article $article Clanek, ktery se komentuje * @param \Nette\Http\Session $session Session pro ulozeni hodnot pri nahledu komentare * @param \Kdyby\Translation\Translator $translator Prekladac * @param \App\Model\Repository\ArticleRepository $repository */ public function __construct(Article $article, \Nette\Http\Session $session, \Kdyby\Translation\Translator $translator, \App\Model\Repository\ArticleRepository $repository) { $this->article = $article; $this->commentSession = $session->getSection('comments'); $this->translator = $translator; $this->articleRepository = $repository; $this->paginator = new \Nette\Utils\Paginator(); $this->paginator->setItemsPerPage(self::COMMENT_PER_PAGE); $this->paginator->setPage(1); }
/** * @param Nette\Application\Application * @param Gettext\Translator\Gettext * @param Nette\Http\Session * @param Nette\Http\Request * @param string * @param int */ public function __construct(Nette\Application\Application $application, Gettext $translator, Nette\Http\Session $session, Nette\Http\Request $httpRequest, $layout, $height) { $this->application = $application; $this->translator = $translator; $this->sessionStorage = $session->getSection(Gettext::$namespace); $this->httpRequest = $httpRequest; $this->height = $height; $this->layout = $layout; $this->processRequest(); }
/** * @param PayPal $payPal * @param Session $session */ public function __construct(PayPal $payPal, Session $session) { parent::__construct(); $this->payPal = $payPal; $this->session = $session->getSection('PayPalExpress'); $this->session->setExpiration('+10 minutes'); if (empty($this->session->token)) { $this->session->token = $this->_ec = Strings::random(6); } }
public function __construct(Nette\Http\Session $session, Nette\Caching\IStorage $cacheStorage, Nette\Http\Response $httpResponse, FileManager $fileManager) { $this->sessionStorage = $sessionStorage = $session->getSection(self::$namespace); $this->cache = new Nette\Caching\Cache(new Nette\Caching\Storages\DevNullStorage(), self::$namespace); $this->httpResponse = $httpResponse; $this->fileManager = $fileManager; /* if (!isset($sessionStorage->newStrings) || !is_array($sessionStorage->newStrings)) { $sessionStorage->newStrings = array(); } */ }
public function __construct(EntityManagerInterface $entityManager, Session $session, $cashPaymentAvailable, $bankPaymentAvailable, $cardPaymentAvailable) { parent::__construct($entityManager); $this->repository = $entityManager->getRepository(Order::class); $this->entityManager = $entityManager; $orderSession = $session->getSection('order'); $orderSession->setExpiration('+ 30 minutes'); $this->orderSession = $orderSession; $this->cashPaymentAvailable = (bool) $cashPaymentAvailable; $this->bankPaymentAvailable = (bool) $bankPaymentAvailable; $this->cardPaymentAvailable = (bool) $cardPaymentAvailable; }
/** * @param Form $form */ public function processForm(Form $form) { $values = $form->getValues(); $login = $this->session->getSection('login'); if (isset($login->counter) && $login->counter > 5) { sleep(2); } if ($values->remember) { $this->user->setExpiration('14 days', FALSE); } else { $this->user->setExpiration('20 minutes', TRUE); } try { $this->user->login($values->username, $values->password); $login->counter = 0; $this->onSuccess(); } catch (AuthenticationException $e) { $login->counter++; $form->addError($e->getMessage()); } }
public function __construct(Messages $messages, Nette\Http\Session $session, Github\Api $api, User $user = NULL) { $this->session = $session->getSection('milo.github.nette-extension'); $this->api = $api; $this->user = $user; foreach ($messages->getAll() as $message) { $this->onMessage($message); } # Change handler $api->getClient()->onRequest([$this, 'onMessage']); $api->getClient()->onResponse([$this, 'onMessage']); }
/** * Returns and initializes $this->sessionSection. * * @return SessionSection */ protected function getSessionSection($need) { if ($this->sessionSection !== null) { return $this->sessionSection; } if (!$need && !$this->sessionHandler->exists()) { return null; } $this->sessionSection = $section = $this->sessionHandler->getSection('Nette.Http.UserStorage/' . $this->namespace); if (!$section->identity instanceof IIdentity || !is_bool($section->authenticated)) { $section->remove(); } if ($section->authenticated && $section->expireBrowser && !$section->browserCheck) { // check if browser was closed? $section->reason = self::BROWSER_CLOSED; $section->authenticated = false; if ($section->expireIdentity) { unset($section->identity); } } if ($section->authenticated && $section->expireDelta > 0) { // check time expiration if ($section->expireTime < time()) { $section->reason = self::INACTIVITY; $section->authenticated = false; if ($section->expireIdentity) { unset($section->identity); } } $section->expireTime = time() + $section->expireDelta; // sliding expiration } if (!$section->authenticated) { unset($section->expireTime, $section->expireDelta, $section->expireIdentity, $section->expireBrowser, $section->browserCheck, $section->authTime); } return $this->sessionSection; }
/** * @return \Nette\Http\SessionSection */ protected function getSession() { return $this->session->getSection(self::SESSION_SECTION); }
/** * @param string $identifier * @param Session $session */ public function __construct($identifier, Session $session) { $this->cache = $session->getSection('Architect.' . $this->getClass() . '.' . $identifier); $this->identifier = $identifier; $this->startup(); }
/** * @param Session $session * @param Product $productService */ public function __construct(Session $session, Product $productService) { $this->section = $session->getSection(self::BASKET_SECTION); $this->productService = $productService; }