コード例 #1
0
ファイル: WidgetTest.php プロジェクト: ramunasd/platform
 public function testDashboard()
 {
     $dashboard = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\Dashboard');
     $this->assertNull($this->widget->getDashboard());
     $this->assertEquals($this->widget, $this->widget->setDashboard($dashboard));
     $this->assertEquals($dashboard, $this->widget->getDashboard());
 }
コード例 #2
0
 /**
  * @depends testPut
  */
 public function testDelete()
 {
     $this->client->request('DELETE', $this->getUrl('oro_api_delete_dashboard_widget', ['dashboardId' => $this->widget->getDashboard()->getId(), 'widgetId' => $this->widget->getId()]));
     $result = $this->client->getResponse();
     $this->assertEmptyResponseStatusCodeEquals($result, 204);
     $this->client->request('DELETE', $this->getUrl('oro_api_delete_dashboard_widget', ['dashboardId' => $this->widget->getDashboard()->getId(), 'widgetId' => $this->widget->getId()]));
     $result = $this->client->getResponse();
     $this->assertJsonResponseStatusCodeEquals($result, 404);
 }
コード例 #3
0
 /**
  * @Route("/configure/{id}", name="oro_dashboard_configure", requirements={"id"="\d+"})
  * @Method({"GET", "POST"})
  * @Template("OroDashboardBundle:Dashboard:dialog/configure.html.twig")
  */
 public function configureAction(Request $request, Widget $widget)
 {
     if (!$this->getSecurityFacade()->isGranted('EDIT', $widget->getDashboard())) {
         throw new AccessDeniedException();
     }
     $form = $this->getFormProvider()->getForm($widget->getName());
     $saved = false;
     $form->setData($this->get('oro_dashboard.widget_configs')->getFormValues($widget));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $widget->setOptions($form->getData());
         $this->getEntityManager()->flush();
         $saved = true;
     }
     return ['form' => $form->createView(), 'formAction' => $request->getRequestUri(), 'saved' => $saved];
 }