scope = $scope; $this->state = $state; } /** * Emulates callback inside adminhtml area code and adminhtml scope. * * Returns the return value of the callback. * * @param callable $callback The callable to be called * @param array $params The parameters to be passed to the callback, as an indexed array * @return bool|int|float|string|array|null - as the result of this method is the result of callback, * you can use callback only with specified in this method return types * @throws \Exception The exception is thrown if the parameter $callback throws an exception */ public function process(callable $callback, array $params = []) { $currentScope = $this->scope->getCurrentScope(); try { return $this->state->emulateAreaCode(Area::AREA_ADMINHTML, function () use ($callback, $params) { $this->scope->setCurrentScope(Area::AREA_ADMINHTML); return call_user_func_array($callback, $params); }); } catch (\Exception $exception) { throw $exception; } finally { $this->scope->setCurrentScope($currentScope); } } }