Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Memory.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 2.73 KiB


001  <?php
002   
003  namespace OAuth\Common\Storage;
004   
005  use OAuth\Common\Token\TokenInterface;
006  use OAuth\Common\Storage\Exception\TokenNotFoundException;
007  use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException;
008   
009  /*
010   * Stores a token in-memory only (destroyed at end of script execution).
011   */
012  class Memory implements TokenStorageInterface
013  {
014      /**
015       * @var object|TokenInterface
016       */
017      protected $tokens;
018   
019      /**
020       * @var array
021       */
022      protected $states;
023   
024      public function __construct()
025      {
026          $this->tokens = array();
027          $this->states = array();
028      }
029   
030      /**
031       * {@inheritDoc}
032       */
033      public function retrieveAccessToken($service)
034      {
035          if ($this->hasAccessToken($service)) {
036              return $this->tokens[$service];
037          }
038   
039          throw new TokenNotFoundException('Token not stored');
040      }
041   
042      /**
043       * {@inheritDoc}
044       */
045      public function storeAccessToken($service, TokenInterface $token)
046      {
047          $this->tokens[$service] = $token;
048   
049          // allow chaining
050          return $this;
051      }
052   
053      /**
054       * {@inheritDoc}
055       */
056      public function hasAccessToken($service)
057      {
058          return isset($this->tokens[$service]) && $this->tokens[$service] instanceof TokenInterface;
059      }
060   
061      /**
062       * {@inheritDoc}
063       */
064      public function clearToken($service)
065      {
066          if (array_key_exists($service, $this->tokens)) {
067              unset($this->tokens[$service]);
068          }
069   
070          // allow chaining
071          return $this;
072      }
073   
074      /**
075       * {@inheritDoc}
076       */
077      public function clearAllTokens()
078      {
079          $this->tokens = array();
080   
081          // allow chaining
082          return $this;
083      }
084   
085      /**
086       * {@inheritDoc}
087       */
088      public function retrieveAuthorizationState($service)
089      {
090          if ($this->hasAuthorizationState($service)) {
091              return $this->states[$service];
092          }
093   
094          throw new AuthorizationStateNotFoundException('State not stored');
095      }
096   
097      /**
098       * {@inheritDoc}
099       */
100      public function storeAuthorizationState($service, $state)
101      {
102          $this->states[$service] = $state;
103   
104          // allow chaining
105          return $this;
106      }
107   
108      /**
109       * {@inheritDoc}
110       */
111      public function hasAuthorizationState($service)
112      {
113          return isset($this->states[$service]) && null !== $this->states[$service];
114      }
115   
116      /**
117       * {@inheritDoc}
118       */
119      public function clearAuthorizationState($service)
120      {
121          if (array_key_exists($service, $this->states)) {
122              unset($this->states[$service]);
123          }
124   
125          // allow chaining
126          return $this;
127      }
128   
129      /**
130       * {@inheritDoc}
131       */
132      public function clearAllAuthorizationStates()
133      {
134          $this->states = array();
135   
136          // allow chaining
137          return $this;
138      }
139  }
140