public function status(Request $request, WidgetInterface $widget, string $widgetId, bool $status = true)
    {
        // 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 Config Parameters
            $widgetConfig->addWidgetConfig($widgetId, ['status' => $status]);

            // Save
            $em = $this->getDoctrine()->getManager();
            $em->persist($widgetConfig);
            $em->flush();
        }

        // Response
        return $this->redirect($request->headers->get('referer') ?? $this->generateUrl($this->getParameter('pd_widget.return_route')));
    }
public function status(Request $request, WidgetInterface $widget, string $widgetId, bool $status = true)
    {
        // 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 Config Parameters
            $widgetConfig->addWidgetConfig($widgetId, ['status' => $status]);

            // Save
            $em = $this->getDoctrine()->getManager();
            $em->persist($widgetConfig);
            $em->flush();
        }

        // Response
        return $this->redirect($request->headers->get('referer') ?? $this->generateUrl($this->getParameter('pd_widget.return_route')));
    }
public function status ( Request $ request , WidgetInterface $ widget , string $ widgetId , bool $ status = true ) { // 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 Config Parameters $ widgetConfig -> addWidgetConfig ( $ widgetId , [ 'status' => $ status ] ) ; // Save $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ widgetConfig ) ; $ em -> flush ( ) ; } // Response return $ this -> redirect ( $ request -> headers -> get ( 'referer' ) ?? $ this -> generateUrl ( $ this -> getParameter ( 'pd_widget.return_route' ) ) ) ; }
Change Widget Status.

@param Request $request
@param string  $widgetId
@param bool    $status

@return \Symfony\Component\HttpFoundation\RedirectResponse
Change Widget Status .