getServiceFactory()->create('Layout')->getForFrontend($params['scope'], $params['name']); } public function actionUpdate($params, $data, $request) { if (is_object($data)) { $data = get_object_vars($data); } if (!$this->getUser()->isAdmin()) { throw new Forbidden(); } if (!$request->isPut() && !$request->isPatch()) { throw new BadRequest(); } $layoutManager = $this->getContainer()->get('layout'); $layoutManager->set($data, $params['scope'], $params['name']); $result = $layoutManager->save(); if ($result === false) { throw new Error("Error while saving layout."); } $this->getContainer()->get('dataManager')->updateCacheTimestamp(); return $layoutManager->get($params['scope'], $params['name']); } public function actionPatch($params, $data, $request) { return $this->actionUpdate($params, $data, $request); } public function postActionResetToDefault($params, $data, $request) { if (!$this->getUser()->isAdmin()) { throw new Forbidden(); } if (empty($data->scope) || empty($data->name)) { throw new BadRequest(); } $this->getContainer()->get('dataManager')->updateCacheTimestamp(); return $this->getContainer()->get('layout')->resetToDefault($data->scope, $data->name); } }