Pimcore: How to check if in editmode/admin area (in php)?

442 views Asked by At

Have googled this but cannot seem to find it... I have a (php) Listener class in which I need to know if i'm currently in admin edit page for a data object (similar to 'editmode' var in twig)... how to do this check in php?

Inside a Controller the editmode is available:

$this->editmode

but how to get this in a class that's not a controller (ie a listener class / any other class)?

2

There are 2 answers

2
Chad On

Have you tried to do same as the Controller (eg. FrontentController) does ? https://github.com/pimcore/pimcore/blob/11.x/lib/Controller/FrontendController.php#L62

Thats the magic behind $this->iseditmode

0
gvanto On

From https://github.com/pimcore/pimcore/discussions/13603:

PimcoreContextAwareTrait and PimcoreContextResolver