/**
  * @param string $formName
  *
  * @return array
  * @throws FormlyMapperException
  */
 public function map($formName = null)
 {
     $formlyConfiguration = [];
     try {
         $configuration = (array) $this->formFactory->getConfiguration($formName);
     } catch (NonExistentFormException $e) {
         throw new FormlyMapperException($e->getMessage());
     }
     if (!empty($configuration)) {
         foreach ($configuration as $fieldName => $fieldConfiguration) {
             $fieldConfiguration['name'] = $fieldName;
             $formlyField = $this->formlyFieldFactory->getFormlyField($fieldConfiguration['type']);
             $formlyField->setFieldConfiguration($fieldConfiguration);
             $formlyConfiguration[] = $formlyField->getFormlyFieldConfiguration();
         }
     }
     $formName = !empty($formName) ? $formName : 'form';
     $token = $this->csrfTokenManager->refreshToken($formName);
     $tokenFieldConfiguration = ['key' => '_token', 'type' => 'hidden', 'defaultValue' => $token->getValue()];
     $formlyConfiguration[] = $tokenFieldConfiguration;
     return $formlyConfiguration;
 }
 /**
  * @expectedException \Linio\DynamicFormBundle\Exception\NonExistentFormException
  */
 public function testIsHandlingNotExistenFormException()
 {
     $configuration = ['foo' => ['email' => ['enabled' => true, 'type' => 'email'], 'password' => ['enabled' => false, 'type' => 'password']]];
     $this->formFactory->setConfiguration($configuration);
     $this->formFactory->getConfiguration('bar');
 }