Form/Type/ResourceType.php
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired(
            [
                'resource_type',
            ]
        );
        $resolver->setDefaults(
            [
                'class' => null,
                'repository' => null,
                'compound' => false,
                'error_bubbling' => false,
            ]
        );
        $resolver->setNormalizer(
            'resource_type',
            function (Options $options, $value) {
                return $this->resourceManager->getResourceTypeConfiguration($value);
            }
        );
        $resolver->setNormalizer(
            'class',
            function (Options $options, $value) {
                $resourceType = $options['resource_type'];
                if (!$value && $resourceType instanceof ResourceTypeConfiguration) {
                    return $resourceType->getEntity();
                }

                return $value;
            }
        );
        $resolver->setNormalizer(
            'repository',
            function (Options $options, $value) {
                if ($value) {
                    if ($value instanceof ObjectRepository) {
                        return $value;
                    }
                    throw new \UnexpectedValueException("The 'repository' option must be an EntityRepository");
                }
                $class = $options['class'];
                if (!$class) {
                    throw new \UnexpectedValueException("Missing option 'class' or 'repository'");
                }

                $entityManager = $this->doctrine->getManagerForClass($class);
                if (!$entityManager instanceof EntityManagerInterface) {
                    throw new \UnexpectedValueException("No manager found for class {$class}");
                }

                return $entityManager->getRepository($class);
            }
        );
    }
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired(
            [
                'resource_type',
            ]
        );
        $resolver->setDefaults(
            [
                'class' => null,
                'repository' => null,
                'compound' => false,
                'error_bubbling' => false,
            ]
        );
        $resolver->setNormalizer(
            'resource_type',
            function (Options $options, $value) {
                return $this->resourceManager->getResourceTypeConfiguration($value);
            }
        );
        $resolver->setNormalizer(
            'class',
            function (Options $options, $value) {
                $resourceType = $options['resource_type'];
                if (!$value && $resourceType instanceof ResourceTypeConfiguration) {
                    return $resourceType->getEntity();
                }

                return $value;
            }
        );
        $resolver->setNormalizer(
            'repository',
            function (Options $options, $value) {
                if ($value) {
                    if ($value instanceof ObjectRepository) {
                        return $value;
                    }
                    throw new \UnexpectedValueException("The 'repository' option must be an EntityRepository");
                }
                $class = $options['class'];
                if (!$class) {
                    throw new \UnexpectedValueException("Missing option 'class' or 'repository'");
                }

                $entityManager = $this->doctrine->getManagerForClass($class);
                if (!$entityManager instanceof EntityManagerInterface) {
                    throw new \UnexpectedValueException("No manager found for class {$class}");
                }

                return $entityManager->getRepository($class);
            }
        );
    }
public function configureOptions ( OptionsResolver $ resolver ) { $ resolver -> setRequired ( [ 'resource_type' , ] ) ; $ resolver -> setDefaults ( [ 'class' => null , 'repository' => null , 'compound' => false , 'error_bubbling' => false , ] ) ; $ resolver -> setNormalizer ( 'resource_type' , function ( Options $ options , $ value ) { return $ this -> resourceManager -> getResourceTypeConfiguration ( $ value ) ; } ) ; $ resolver -> setNormalizer ( 'class' , function ( Options $ options , $ value ) { $ resourceType = $ options [ 'resource_type' ] ; if ( ! $ value && $ resourceType instanceof ResourceTypeConfiguration ) { return $ resourceType -> getEntity ( ) ; } return $ value ; } ) ; $ resolver -> setNormalizer ( 'repository' , function ( Options $ options , $ value ) { if ( $ value ) { if ( $ value instanceof ObjectRepository ) { return $ value ; } throw new \ UnexpectedValueException ( "The 'repository' option must be an EntityRepository" ) ; } $ class = $ options [ 'class' ] ; if ( ! $ class ) { throw new \ UnexpectedValueException ( "Missing option 'class' or 'repository'" ) ; } $ entityManager = $ this -> doctrine -> getManagerForClass ( $ class ) ; if ( ! $ entityManager instanceof EntityManagerInterface ) { throw new \ UnexpectedValueException ( "No manager found for class {$class}" ) ; } return $ entityManager -> getRepository ( $ class ) ; } ) ; }
@param OptionsResolver $resolver

@throws \Symfony\Component\OptionsResolver\Exception\AccessException
@throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
@throws \UnexpectedValueException
@param OptionsResolver $resolver