-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,6 +257,17 @@ protected function createAdmin() : \Aimeos\Admin\JQAdm\Iface | |
$context = app( 'aimeos.context' )->get( false, 'backend' ); | ||
$context->setI18n( app( 'aimeos.i18n' )->get( array( $lang, 'en' ) ) ); | ||
$context->setLocale( app( 'aimeos.locale' )->getBackend( $context, $site ) ); | ||
|
||
$siteManager = \Aimeos\MShop::create( $context, 'locale/site'); | ||
|
||
$filter = $siteManager->filter(); | ||
$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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
$siteConfig = array_pop( $siteConfig ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. The array returned from $site-Item->getConfig()->toArray() is like this: [1] => [ so array_pop returns the full settings array There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
$context->config()->apply( $siteConfig ); | ||
|
||
$view = app( 'aimeos.view' )->create( $context, $paths, $lang ); | ||
|
||
|
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 )
insteadThere 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.