-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Merge custom site configuration on admin pages #466
Merge custom site configuration on admin pages #466
Conversation
Merge custom site configuration on admin pages
|
||
$siteItem = $siteManager->search( $filter->slice( 0 ) ); | ||
$siteConfig = $siteItem->getConfig()->toArray(); | ||
$siteConfig = array_pop( $siteConfig ); |
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.
This seems to be wrong because only one setting will be applied to the config instead of all settings
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.
The array returned from $site-Item->getConfig()->toArray() is like this:
[1] => [
'theme/default/--ai-bg' => '#000000',
'theme/default/--ai-bg-alt' => '#ffffff',
]
so array_pop returns the full settings array
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 have just tested removing ->toArray() from line 267 and this makes array_pop unnecessary so I have removed that too.
$filter->add([ 'locale.site.code' => $site ]); | ||
|
||
$siteItem = $siteManager->search( $filter->slice( 0 ) ); | ||
$siteConfig = $siteItem->getConfig()->toArray(); |
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.
getConfig()
already returns an array, so calling toArray()
should fail
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 did initially try to just use $siteItem->getConfig() but config()->apply($siteConfig) complained that $siteConfig was a Map rather than an array. I think this was because I wasn't popping the config array off of the list returned from the filter/search.
I have just changed this to remove ->toArray() and it works perfectly.
$filter = $siteManager->filter(); | ||
$filter->add([ 'locale.site.code' => $site ]); | ||
|
||
$siteItem = $siteManager->search( $filter->slice( 0 ) ); |
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.
You can use $siteManager->find( $site )
instead
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.
Excellent, that is much better. I have switched to that method.
Fixes and improvements to admin site settings merge as suggested by Aimeos
Great! :-) |
Merge custom site configuration on admin pagesFollowing on from this issue:
aimeos/aimeos-core#296
I have merged the custom site entries on the context of the admin pages.