/**
  * @param  ContainerInterface $container
  * @param  string $name
  * @param  null|array $options
  * @return AnnotationBuilder
  * @throws ServiceNotCreatedException for invalid listener configuration.
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     //setup a form factory which can use custom form elements
     $annotationBuilder = new AnnotationBuilder();
     $eventManager = $container->get('EventManager');
     $annotationBuilder->setEventManager($eventManager);
     $this->injectFactory($annotationBuilder->getFormFactory(), $container);
     $config = $this->marshalConfig($container);
     if (isset($config['preserve_defined_order'])) {
         $annotationBuilder->setPreserveDefinedOrder($config['preserve_defined_order']);
     }
     $this->injectAnnotations($config, $annotationBuilder);
     $this->injectListeners($config, $eventManager, $container);
     return $annotationBuilder;
 }