/** * {@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)) { throw new \InvalidArgumentException(sprintf('The data item "%s" must be an array, but "%s" given.', $key, is_object($val) ? get_class($val) : gettype($val))); } $context->data()->set($key, $this->getDataIdentifier($key, $val), $this->getData($key, $val)); } $context->remove('data'); }
/** * @param ContextInterface $context * * @return string|null */ protected function extractFormEnctype(ContextInterface $context) { $formEnctype = null; if ($context->has('form_enctype')) { $formEnctype = $context->get('form_enctype'); if (!is_string($formEnctype)) { throw new \InvalidArgumentException(sprintf('The "form_enctype" must be a string, but "%s" given.', $this->getTypeName($formEnctype))); } $context->remove('form_enctype'); } return $formEnctype; }