/** * Runs a callback function in the legacy kernel environment. * This is useful to run eZ Publish 4.x code from a non-related context (like eZ Publish 5) * * @param \Closure $callback * @param boolean $postReinitialize Default is true. * If set to false, the kernel environment will not be reinitialized. * This can be useful to optimize several calls to the kernel within the same context. * @return mixed The result of the callback */ public function runCallback(\Closure $callback, $postReinitialize = true) { if (!$this->script->isInitialized()) { $this->script->initialize(); } $return = $callback(); $this->script->shutdown(); if (!$postReinitialize) { $this->script->setIsInitialized(true); } return $return; }