-
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
configuration cannot be merge and must replace #7
Conversation
Unfortunately this leads to other problem cases. Example: $config = [
'tinymce_jquery' => true,
'theme' => [
'advanced' => [
'theme' => 'modern',
'plugins' => [
'p1 p2',
'p3 p4'
]
]
]
];
$options = [
'theme' => [
'advanced' => [
'plugins' => [
'p4 p5'
]
]
]
];
$config = array_replace_recursive($config, $options); gives Array
(
[tinymce_jquery] => 1
[theme] => Array
(
[advanced] => Array
(
[theme] => modern
[plugins] => Array
(
[0] => p4 p5
[1] => p3 p4
)
)
)
) No real easy way to solve all cases here. |
Yes.. and even if we do a good merge, it's impossible to determine if some values must be combined or overwritten. This lead to the question : if we cannot handle correctly this, should we implement this ? |
As the PR introducing this came from me, I'd say yes. :D What do you think about: public function tinymceInit($options = array(), $replace = false)
{
$config = $this->getParameter('stfalcon_tinymce.config');
if ($replace) {
$config = array_replace_recursive($config, $options);
} else {
$config = array_merge_recursive($config, $options);
}
// ...
} That way the user can decide which method fits. |
Yes, it look like a good solution. 👍 |
I was also thinking about the configuration. TinyMCE's one is pretty big and complex (see here), and maybe it will change from release to release; that's why I don't think it is the best solution to map it into our bundle's YAML configuration. What do you guys think about converting all the children of the
that becomes
Optionally we could add a simple validation for the children of our |
👍 |
@Ingannatore This is exactly what we have now. The tinymceInit twig function gets the config from YAML, does some pre-processing and then JSON encodes it. This is processed in JavaScript depending if unsing TinyMCE with or without jQuery and then passed to init TinyMCE. |
@nykopol if you implement the changes proposed by @MisatoTremor in #7 (comment), I'll be happy to merge since that will fix the immediate problem. Further enhancements to the configuration handling will be postponed to future releases. Thanks to everyone for the comments and contribution! |
@MisatoTremor yes, but it works only for the options defined inside the file |
@zanardigit Ok, i to that. |
That's true, but you can at least do so by passing this config in twig. |
@zanardigit it added proposal of @MisatoTremor with a small doc in the readme. I think this PR can be merge. |
configuration cannot be merge and must replace
Merge options with array_merge_recursive lead to unusable configuration. For example, if we overwrite
tinymce_jquery
the resulting value istinymce_jquery: [true, false]
witch is a non-sense.