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

Merge custom site configuration on admin pages #466

Merged
merged 2 commits into from
Aug 26, 2022

Conversation

defive
Copy link
Contributor

@defive defive commented Aug 25, 2022

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.

Merge custom site configuration on admin pages

$siteItem = $siteManager->search( $filter->slice( 0 ) );
$siteConfig = $siteItem->getConfig()->toArray();
$siteConfig = array_pop( $siteConfig );
Copy link
Owner

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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();
Copy link
Owner

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

Copy link
Contributor Author

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.

Comment on lines 263 to 266
$filter = $siteManager->filter();
$filter->add([ 'locale.site.code' => $site ]);

$siteItem = $siteManager->search( $filter->slice( 0 ) );
Copy link
Owner

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

Copy link
Contributor Author

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
@aimeos
Copy link
Owner

aimeos commented Aug 26, 2022

Great! :-)

@aimeos aimeos merged commit f186501 into aimeos:master Aug 26, 2022
@defive defive deleted the merge-custom-site-config-on-admin-pages branch September 26, 2022 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants