. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Controllers; use Espo\Core\Exceptions\BadRequest; use Espo\Core\Exceptions\Error; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Api\Request; use Espo\Tools\App\SettingsService as Service; use Espo\Entities\User; use stdClass; class Settings { public function __construct( private Service $service, private User $user, ) {} public function getActionRead(): stdClass { return $this->getConfigData(); } /** * @throws BadRequest * @throws Forbidden * @throws Error */ public function putActionUpdate(Request $request): stdClass { if (!$this->user->isAdmin()) { throw new Forbidden(); } $data = $request->getParsedBody(); $this->service->setConfigData($data); return $this->getConfigData(); } private function getConfigData(): stdClass { $data = $this->service->getConfigData(); $metadataData = $this->service->getMetadataConfigData(); foreach (get_object_vars($metadataData) as $key => $value) { $data->$key = $value; } return $data; } }