-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to split different user sessions for one stepped form depending on initial data
- Loading branch information
Showing
13 changed files
with
196 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lexal\SteppedForm\Exception; | ||
|
||
final class ReadSessionKeyException extends SteppedFormException | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('Unable to get current form session key.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lexal\SteppedForm\Form\Storage; | ||
|
||
use Lexal\SteppedForm\SteppedFormInterface; | ||
|
||
final class NullSessionStorage implements SessionStorageInterface | ||
{ | ||
public function getCurrent(): ?string | ||
{ | ||
return SteppedFormInterface::DEFAULT_SESSION_KEY; | ||
} | ||
|
||
public function setCurrent(string $sessionKey): void | ||
{ | ||
// nothing to save | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lexal\SteppedForm\Form\Storage; | ||
|
||
use Lexal\SteppedForm\Exception\ReadSessionKeyException; | ||
|
||
interface SessionStorageInterface | ||
{ | ||
/** | ||
* Returns current session key. Throws an exception when cannot read session key from the storage. | ||
* Returns null if there is no started form. | ||
* | ||
* @throws ReadSessionKeyException | ||
*/ | ||
public function getCurrent(): ?string; | ||
|
||
/** | ||
* Save current session key to the storage. | ||
*/ | ||
public function setCurrent(string $sessionKey): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lexal\SteppedForm\Tests; | ||
|
||
use Lexal\SteppedForm\Form\Storage\SessionStorageInterface; | ||
|
||
final class InMemorySessionStorage implements SessionStorageInterface | ||
{ | ||
private ?string $sessionKey = null; | ||
|
||
public function getCurrent(): ?string | ||
{ | ||
return $this->sessionKey; | ||
} | ||
|
||
public function setCurrent(string $sessionKey): void | ||
{ | ||
$this->sessionKey = $sessionKey; | ||
} | ||
} |
Oops, something went wrong.