getSection() public method

Returns specified session section.
public getSection ( $section, $class = SessionSection::class ) : SessionSection
return SessionSection
コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
ファイル: Panel.php プロジェクト: klimesf/gettext-translator
 /**
  * Sets debug mode.
  * @param boolean $debugMode
  */
 public function setDebugMode($debugMode)
 {
     $this->debugMode = $debugMode;
     if ($debugMode === true) {
         $this->sessionStorage = $this->session->getSection(Gettext::$namespace);
     }
 }
コード例 #3
0
ファイル: Session.php プロジェクト: mesour/nette-bridges
 /**
  * @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));
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 /**
  * @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());
 }
コード例 #6
0
ファイル: AuthorizatorFactory.php プロジェクト: venne/venne
 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;
 }
コード例 #7
0
ファイル: AuthorizatorFactory.php プロジェクト: svobodni/web
 /**
  * @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;
 }
コード例 #8
0
ファイル: Presenter.php プロジェクト: voda/application
 /**
  * @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);
 }
コード例 #9
0
ファイル: Presenter.php プロジェクト: pdostal/nette-blog
 /**
  * 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]);
 }
コード例 #10
0
 /**
  * @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');
 }
コード例 #11
0
 /**
  * @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);
 }
コード例 #12
0
ファイル: DatabaseGenerator.php プロジェクト: zaxxx/zaxcms
 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');
 }
コード例 #13
0
ファイル: Linkedin.php プロジェクト: lukdanek/linkedin-nette
 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;
 }
コード例 #14
0
ファイル: Grid.php プロジェクト: natrim/gridito
 /**
  * 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;
 }
コード例 #15
0
ファイル: FilesControl.php プロジェクト: venne/files
 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;
 }
コード例 #16
0
ファイル: RatingManager.php プロジェクト: kivi8/ars-poetica
 public function setOldSessId()
 {
     $id = $this->session->getSection('voteId');
     if (empty($id->id)) {
         $this->oldId = false;
     } else {
         $this->oldId = $id->id;
     }
 }
コード例 #17
0
ファイル: Gettext.php プロジェクト: salamek/gettexttranslator
 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();
     }
 }
コード例 #18
0
ファイル: RequestStorage.php プロジェクト: enumag/application
 /**
  * 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;
 }
コード例 #19
0
 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));
     }
 }
コード例 #20
0
ファイル: CommentsFactory.php プロジェクト: krupaj/my-blog
 /**
  * @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);
 }
コード例 #21
0
ファイル: Panel.php プロジェクト: salamek/gettexttranslator
 /**
  * @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();
 }
コード例 #22
0
ファイル: PayControl.php プロジェクト: Hajneej/PayPalExpress
 /**
  * @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);
     }
 }
コード例 #23
0
 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();
     }
     */
 }
コード例 #24
0
ファイル: OrderService.php プロジェクト: shophp/shophp
 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;
 }
コード例 #25
0
 /**
  * @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());
     }
 }
コード例 #26
0
ファイル: Panel.php プロジェクト: milo/github-api-nette
 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']);
 }
コード例 #27
0
 /**
  * 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;
 }
コード例 #28
0
ファイル: AbstractDialog.php プロジェクト: lookyman/u2f-nette
 /**
  * @return \Nette\Http\SessionSection
  */
 protected function getSession()
 {
     return $this->session->getSection(self::SESSION_SECTION);
 }
コード例 #29
0
 /**
  * @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();
 }
コード例 #30
0
ファイル: BasketService.php プロジェクト: pogodi/Site
 /**
  * @param Session $session
  * @param Product $productService
  */
 public function __construct(Session $session, Product $productService)
 {
     $this->section = $session->getSection(self::BASKET_SECTION);
     $this->productService = $productService;
 }