-
Notifications
You must be signed in to change notification settings - Fork 6
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
fixes #30 #31
base: release_8
Are you sure you want to change the base?
fixes #30 #31
Conversation
@@ -525,20 +525,24 @@ protected function setStyleFromProps(ilTemplate $tpl, array $properties) | |||
$tpl->setVariable('RATIO', $ratio); | |||
$tpl->setVariable('MAX-WIDTH', $properties[self::PROP_WIDTH]); | |||
$tpl->setVariable('MAX-HEIGHT', $properties[self::PROP_HEIGHT]); | |||
if ($properties[self::PROP_RESPONSIVE] != false) { | |||
$tpl->setVariable('WIDTH', 'width:100%;'); | |||
if (array_key_exists(self::PROP_RESPONSIVE, $properties)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use a Null Coalescing Operator:
if ((bool)($properties[self::PROP_RESPONSIVE] ?? false) === true) {
$tpl->setVariable('WIDTH', 'width:100%;');
}
as well as a more strict type handling, and last but not least turning the logic from != false to === true which is more readable.
$tpl->setVariable('CONTAINER_STYLE', 'text-align:left;'); | ||
break; | ||
if (array_key_exists(self::PROP_POSITION, $properties)) { | ||
switch ($properties[self::PROP_POSITION]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, instead of using array_key_exists you can just use
switch ($properties[self::PROP_POSITION] ?? null) {
Can we fix the error and transfer it to the production version? |
Thank you, I changed the PR and added your suggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will merge this to the next release!
I added a check with array_key_exists() to fix #30