Skip to content

Commit

Permalink
refs #2642 Added config/screen param to avoid breaking backward compa…
Browse files Browse the repository at this point in the history
…tibility
  • Loading branch information
tabuna committed Jun 19, 2023
1 parent b6d593d commit 1371899
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@

'prevents_abandonment' => true,

/*
|--------------------------------------------------------------------------
| Preserve Entire Screen State
|--------------------------------------------------------------------------
|
| This option determines whether the entire screen state should be preserved
| between requests. Enabling this option allows for the full state of the screen
| to be retained, including private fields, which can be useful for listeners.
| Disabling this option will only retain public properties.
|
*/

'full_state' => true,

/*
|--------------------------------------------------------------------------
| Service Provider
Expand Down
13 changes: 13 additions & 0 deletions src/Screen/Screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ protected function buildQueryRepository(array $httpQueryArguments = []): Reposit
*/
public function serializeStateWithPublicProperties(Repository $repository): string
{
if ($this->isScreenFullStatePreserved()) {
return $this->serializableState($repository);
}

$propertiesToSerialize = $repository->getMany($this->getPublicPropertyNames()->toArray());

return $this->serializableState(new Repository($propertiesToSerialize));
Expand Down Expand Up @@ -378,6 +382,15 @@ public function needPreventsAbandonment(): bool
return config('platform.prevents_abandonment', true);
}

/**
* Check if the screen state preservation feature is enabled.
* Returns true if enabled, false otherwise.
*/
public function isScreenFullStatePreserved(): bool
{
return config('screen.full_state', true);
}

/**
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \ReflectionException
Expand Down

0 comments on commit 1371899

Please sign in to comment.