-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Block config not always of the same type in block PHP section #23
Comments
Can we have a PR that just always converts it to either a stdClass or an array? |
It's on my to-do list ... but I'm running out of time. Which type do you think is best? |
Since configs are ultimately stored through Halcyon (ie. the static content files in the theme), I think it should be an array for the best compatibility with that. |
Block configs do not have to be used only with static pages, so I wouldn't necessarily use that as the deciding factor @bennothommo unless it actively causes issues to be in an stdClass form. But yes, for simplicities sake I would prefer they were stored as arrays. |
@LukeTowers @bennothommo Why not use the It provides access to data in two ways: use Illuminate\Support\Fluent;
$dataArray = ['color'=> 'red', 'size'=> null];
$dataStdClass = $dataArray;
// From an array
$dataFluent = new Fluent($dataArray);
$dataFluent['size']; // null
$dataFluent['color']; // red
$dataFluent->size; // null
$dataFluent->color; // red
// From an array
$dataFluent = new Fluent($dataStdClass);
$dataFluent['size']; // null
$dataFluent['color']; // red
$dataFluent->size; // null
$dataFluent->color; // red |
@damsfx I'm happy to approve a PR adding that :) |
Context :
a block that define a config according to the documentation.
Case 1 :
Block added to the page, nothing changed in content, open/close the config inspector, page saved.
The config is available in the PHP section of the block as a
sdtClass
.Case 2 :
Block added to the page, nothing changed in content, page saved.
The config is available in the PHP section of the block as an
array
.Workaround :
Strictly typing the configuration,
As an array :
As an stdClass :
The text was updated successfully, but these errors were encountered: