I'm using Sonata Admin bundle in my Symfony project. I see many console log messages in the browser generated by Sonata admin bundle.
These messages are generated by Sonata Admin from /vendor/sonata-project/admin-bundle/src/Resources/public/Admin.js by the code,
/**
* render log message
* @param mixed
*/
log: function() {
var msg = '[Sonata.Admin] ' + Array.prototype.join.call(arguments,', ');
if (window.console && window.console.log) {
window.console.log(msg);
} else if (window.opera && window.opera.postError) {
window.opera.postError(msg);
}
},
Does anyone know how to disable these log messages? I don't even get any kind of result from Google search. Is there a way to control these from configuration file or something?
Thanks in advance!!
I have opened a issue in Sonata Admin GitHub repo https://github.com/sonata-project/SonataAdminBundle/issues/5278 and found the solution.
You have to override the sonata admin's standard_layout like,
/config/packages/sonata_admin.yaml
sonata_admin
templates:
layout: 'sonata_admin/layout.html.twig'
Now create layout.html.twig inside /templates/sonata_admin/ and use the following code.
{% extends '@SonataAdmin/standard_layout.html.twig' %}
{% block javascripts %}
{{ parent() }}
<script>
if ('undefined' !== typeof window.Admin) {
window.Admin.log = function() {}
}
</script>
{% endblock %}