Get current admin user || Set custom cke settings for user role



I’m trying to get the current admin user in my view to set custom CKE settings if the user is not an admin.

I found several other projects that use the following:

$currentUser = \Pimcore\Tool\Admin::getCurrentUser();

But for me this is always null. Therefor my question is:
How do I get the current admin user in a view?

Or is there a smarter way to set custom cke settings to a certain user role?

Thanks a lot!



I am attempting to do the same thing; to find out whether the currently logged administration user has admin rights or not, like so:


But this always returns null in my DefaultController (from the AppBundle).

I suspect that happens because the structures containing this information are somehow separated, i.e. the information about the backend user is not available from frontend.

What I need this for: I want to display a custom backend menu button (to reindex ElasticSearch) and use a method in the DefaultController that returns bool – whether to display the button or not – via an AJAX request made from backend.js extension file.

Any way of solving this? Thanks!