NullSession.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Model\Session;
  6. use Magento\Framework\DataObject;
  7. use Magento\Framework\Session\SessionManagerInterface;
  8. /**
  9. * Temando Shipping Carrier
  10. *
  11. * @package Temando\Shipping\Model
  12. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  13. * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
  14. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  15. * @link http://www.temando.com/
  16. */
  17. class NullSession extends DataObject implements SessionManagerInterface
  18. {
  19. /**
  20. * Start session
  21. *
  22. * @return SessionManagerInterface
  23. */
  24. public function start()
  25. {
  26. return $this;
  27. }
  28. /**
  29. * Session write close
  30. *
  31. * @return void
  32. */
  33. public function writeClose()
  34. {
  35. }
  36. /**
  37. * Does a session exist
  38. *
  39. * @return bool
  40. */
  41. public function isSessionExists()
  42. {
  43. return true;
  44. }
  45. /**
  46. * Retrieve session Id
  47. *
  48. * @return string
  49. */
  50. public function getSessionId()
  51. {
  52. return "1";
  53. }
  54. /**
  55. * Retrieve session name
  56. *
  57. * @return string
  58. */
  59. public function getName()
  60. {
  61. return "NullSession";
  62. }
  63. /**
  64. * Set session name
  65. *
  66. * @param string $name
  67. *
  68. * @return SessionManagerInterface
  69. */
  70. public function setName($name)
  71. {
  72. return $this;
  73. }
  74. /**
  75. * Destroy/end a session
  76. *
  77. * @param array $options
  78. *
  79. * @return void
  80. */
  81. public function destroy(array $options = null)
  82. {
  83. }
  84. /**
  85. * Unset session data
  86. *
  87. * @return $this
  88. */
  89. public function clearStorage()
  90. {
  91. return $this;
  92. }
  93. /**
  94. * Retrieve Cookie domain
  95. *
  96. * @return string
  97. */
  98. public function getCookieDomain()
  99. {
  100. return "NullCookieDomain";
  101. }
  102. /**
  103. * Retrieve cookie path
  104. *
  105. * @return string
  106. */
  107. public function getCookiePath()
  108. {
  109. return "NullCookiePath";
  110. }
  111. /**
  112. * Retrieve cookie lifetime
  113. *
  114. * @return int
  115. */
  116. public function getCookieLifetime()
  117. {
  118. return 111111111;
  119. }
  120. /**
  121. * Specify session identifier
  122. *
  123. * @param string|null $sessionId
  124. *
  125. * @return SessionManagerInterface
  126. */
  127. public function setSessionId($sessionId)
  128. {
  129. return $this;
  130. }
  131. /**
  132. * Renew session id and update session cookie
  133. *
  134. * @return SessionManagerInterface
  135. */
  136. public function regenerateId()
  137. {
  138. return $this;
  139. }
  140. /**
  141. * Expire the session cookie
  142. *
  143. * Sends a session cookie with no value, and with an expiry in the past.
  144. *
  145. * @return void
  146. */
  147. public function expireSessionCookie()
  148. {
  149. }
  150. /**
  151. * If session cookie is not applicable due to host or path mismatch - add session id to query
  152. *
  153. * @param string $urlHost
  154. *
  155. * @return string
  156. */
  157. public function getSessionIdForHost($urlHost)
  158. {
  159. return "NullSessionIdForHosts";
  160. }
  161. /**
  162. * Check if session is valid for given hostname
  163. *
  164. * @param string $host
  165. *
  166. * @return bool
  167. */
  168. public function isValidForHost($host)
  169. {
  170. return true;
  171. }
  172. /**
  173. * Check if session is valid for given path
  174. *
  175. * @param string $path
  176. *
  177. * @return bool
  178. */
  179. public function isValidForPath($path)
  180. {
  181. return true;
  182. }
  183. }