code: public function configs(Request $request, WidgetInterface $widget, CacheInterface $cache, string $widgetId)
      {
          // Build Widget
          $widgets = $widget->getWidgets();
  
          if (isset($widgets[$widgetId])) {
              // Get User Widgets
              $widgetConfig = $this->getDoctrine()
                      ->getRepository('PdWidgetBundle:WidgetUser')
                      ->findOneBy(['owner' => $this->getUser()]) ?? (new WidgetUser())->setOwner($this->getUser());
  
              // Add or Remove Config Parameters
              if ($request->get('remove')) {
                  $widgetConfig->removeWidgetConfig($widgetId, $widgets[$widgetId]->getConfigProcess($request) ?? []);
              } else {
                  $widgetConfig->addWidgetConfig($widgetId, $widgets[$widgetId]->getConfigProcess($request) ?? []);
              }
  
              // Save
              $em = $this->getDoctrine()->getManager();
              $em->persist($widgetConfig);
              $em->flush();
  
              // Flush Widget Cache
              $cache->delete($widgetId.$this->getUser()->getId());
          }
  
          // Response
          return $this->redirect($request->headers->get('referer') ?? $this->generateUrl($this->getParameter('pd_widget.return_route')));
      }
docs: Change Widget Configuration.
  
  @param Request $request
  @param string  $widgetId
  
  @return \Symfony\Component\HttpFoundation\RedirectResponse