Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Areablock: Accept array for setDataFromResource() #16773

Open
wants to merge 2 commits into
base: 11.2
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion models/Document/Editable/Areablock.php
Expand Up @@ -248,7 +248,11 @@ protected function getEditableHandler(): EditableHandler

public function setDataFromResource(mixed $data): static
{
$unserializedData = Tool\Serialize::unserialize($data);
if (is_string($data)) {
$unserializedData = Tool\Serialize::unserialize($data);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove the else and just set $unserializedData = $data as default no?

Copy link
Contributor Author

@blankse blankse Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattamon This was possible, but I made it more type safe. It was possible to put a wrong type and nothing happens. I think it should be throw a InvalidArgumentException() like in the renderlet editable.

$unserializedData = $data;
}

if (is_array($unserializedData)) {
$this->indices = $unserializedData;
Expand Down