コード例 #1
0
ファイル: WidgetTest.php プロジェクト: ramunasd/platform
 public function testName()
 {
     $this->assertNull($this->widget->getName());
     $value = 'test';
     $this->assertEquals($this->widget, $this->widget->setName($value));
     $this->assertEquals($value, $this->widget->getName());
 }
コード例 #2
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];
 }
コード例 #3
0
ファイル: WidgetConfigs.php プロジェクト: anyt/platform
 /**
  * @param Widget $widget
  * @return array
  */
 public function getFormValues(Widget $widget)
 {
     $options = $widget->getOptions();
     $widgetConfig = $this->configProvider->getWidgetConfig($widget->getName());
     foreach ($widgetConfig['configuration'] as $name => $config) {
         $value = isset($options[$name]) ? $options[$name] : null;
         $options[$name] = $this->valueProvider->getFormValue($config['type'], $config, $value);
     }
     $options = $this->loadDefaultValue($options, $widgetConfig);
     return $options;
 }
コード例 #4
0
ファイル: Manager.php プロジェクト: xamin123/platform
 /**
  * Copy widget model by entity
  *
  * @param Widget $sourceWidget
  *
  * @return WidgetModel
  */
 protected function copyWidgetModel(Widget $sourceWidget)
 {
     $widget = new Widget();
     $widget->setLayoutPosition($sourceWidget->getLayoutPosition());
     $widget->setName($sourceWidget->getName());
     return $this->getWidgetModel($widget);
 }
コード例 #5
0
ファイル: Factory.php プロジェクト: Maksold/platform
 /**
  * @param Widget $widget
  * @return WidgetModel
  */
 public function createWidgetModel(Widget $widget)
 {
     $widgetConfig = $this->configProvider->getWidgetConfig($widget->getName());
     $widgetState = $this->stateManager->getWidgetState($widget);
     return new WidgetModel($widget, $widgetConfig, $widgetState);
 }