Пример #1
0
 /**
  * Returns a list of options for widget with id $widgetId or current widget if $widgetId is not specified
  *
  * @param int|null $widgetId
  *
  * @return WidgetOptionBag
  */
 public function getWidgetOptions($widgetId = null)
 {
     $widgetId = is_null($widgetId) && $this->request ? $this->request->query->get('_widgetId', null) : $widgetId;
     if (!$widgetId) {
         return new WidgetOptionBag();
     }
     if (!empty($this->widgetOptionsById[$widgetId])) {
         return new WidgetOptionBag($this->widgetOptionsById[$widgetId]);
     }
     $widget = $this->findWidget($widgetId);
     $widgetConfig = $this->configProvider->getWidgetConfig($widget->getName());
     $options = $widget->getOptions();
     foreach ($widgetConfig['configuration'] as $name => $config) {
         $value = isset($options[$name]) ? $options[$name] : null;
         $options[$name] = $this->valueProvider->getConvertedValue($widgetConfig, $config['type'], $value, $config, $options);
     }
     $this->widgetOptionsById[$widgetId] = $options;
     return new WidgetOptionBag($options);
 }
Пример #2
0
 public function testGetConvertedValue()
 {
     $value = 'test value';
     $this->assertSame('test value', $this->provider->getConvertedValue([], 'test_form_type', $value));
 }