/** * Returns widget attributes with attribute name converted to use in widget's TWIG template * * @param string $widgetName The name of widget * * @return array */ public function getWidgetAttributesForTwig($widgetName) { $result = ['widgetName' => $widgetName]; $widget = $this->configProvider->getWidgetConfig($widgetName); unset($widget['route']); unset($widget['route_parameters']); unset($widget['acl']); unset($widget['items']); $options = $widget['configuration']; foreach ($options as $name => $config) { $widget['configuration'][$name]['value'] = $this->valueProvider->getViewValue($config['type'], $this->getWidgetOptions()->get($name)); } foreach ($widget as $key => $val) { $attrName = 'widget'; foreach (explode('_', str_replace('-', '_', $key)) as $keyPart) { $attrName .= ucfirst($keyPart); } $result[$attrName] = $val; } // get grid params, if exists, this line is required // to not override params passed via request to controller $gridParams = $this->request ? $this->request->get('params', []) : []; if (!empty($gridParams)) { $result['params'] = $this->addGridConfigParams($gridParams); } return $result; }
/** * Returns widget attributes with attribute name converted to use in widget's TWIG template * * @param string $widgetName The name of widget * * @return array */ public function getWidgetAttributesForTwig($widgetName) { $result = ['widgetName' => $widgetName]; $widget = $this->configProvider->getWidgetConfig($widgetName); unset($widget['route']); unset($widget['route_parameters']); unset($widget['acl']); unset($widget['items']); $options = $widget['configuration']; foreach ($options as $name => $config) { $widget['configuration'][$name]['value'] = $this->valueProvider->getViewValue($config['type'], $this->getWidgetOptions()->get($name)); } foreach ($widget as $key => $val) { $attrName = 'widget'; foreach (explode('_', str_replace('-', '_', $key)) as $keyPart) { $attrName .= ucfirst($keyPart); } $result[$attrName] = $val; } return $result; }
public function testGetViewValue() { $value = 'test'; $this->assertSame('test view value', $this->provider->getViewValue('test_form_type', $value)); }