/**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     if (!$context->has('data')) {
         return;
     }
     $data = $context->get('data');
     if (!is_array($data)) {
         return;
     }
     foreach ($data as $key => $val) {
         if (!is_string($key)) {
             throw new \InvalidArgumentException(sprintf('The data key "%s" must be a string, but "%s" given.', $key, gettype($key)));
         }
         if (is_array($val)) {
             $context->data()->set($key, $this->getDataIdentifier($key, $val), $this->getData($key, $val));
         } else {
             $context->data()->set($key, null, $val);
         }
     }
     $context->remove('data');
 }
 /**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $request = $this->requestStack->getCurrentRequest();
     $context->getResolver()->setDefaults(['widget_container' => function (Options $options, $value) use($request) {
         if (null === $value && $request) {
             $value = $request->query->get('_widgetContainer') ?: $request->request->get('_widgetContainer');
         }
         return $value;
     }])->setAllowedTypes(['widget_container' => ['string', 'null']]);
     $context->data()->setDefault('widget_id', '$request._wid', function () use($request) {
         if (!$request) {
             throw new \BadMethodCallException('The request expected.');
         }
         return $request->query->get('_wid') ?: $request->request->get('_wid');
     });
 }