public function generate($schema, $className, Context $context)
    {
        $files   = [];
        $classes = [];

        foreach ($schema->getClasses() as $class) {
            $methods   = [];
            $modelFqdn = $schema->getNamespace()."\\Model\\".$class->getName();
            $methods[] = $this->createSupportsDenormalizationMethod($modelFqdn);
            $methods[] = $this->createSupportsNormalizationMethod($modelFqdn);
            $methods[] = $this->createDenormalizeMethod($modelFqdn, $context, $class->getProperties());
            $methods[] = $this->createNormalizeMethod($modelFqdn, $context, $class->getProperties());

            $normalizerClass = $this->createNormalizerClass(
                $class->getName().'Normalizer',
                $methods
            );
            $classes[] = $normalizerClass->name;

            $namespace = new Stmt\Namespace_(new Name($schema->getNamespace()."\\Normalizer"), [
                new Stmt\Use_([new Stmt\UseUse(new Name('Joli\Jane\Runtime\Reference'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Exception\InvalidArgumentException'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\NormalizerInterface'))]),
                $normalizerClass
            ]);
            $files[]   = new File($schema->getDirectory().'/Normalizer/'.$class->getName().'Normalizer.php', $namespace, self::FILE_TYPE_NORMALIZER);
        }

        $files[] = new File(
            $schema->getDirectory().'/Normalizer/NormalizerFactory.php',
            new Stmt\Namespace_(new Name($schema->getNamespace()."\\Normalizer"), [
                $this->createNormalizerFactoryClass($classes)
            ]),
            self::FILE_TYPE_NORMALIZER
        );

        return $files;
    }
public function generate($schema, $className, Context $context)
    {
        $files   = [];
        $classes = [];

        foreach ($schema->getClasses() as $class) {
            $methods   = [];
            $modelFqdn = $schema->getNamespace()."\\Model\\".$class->getName();
            $methods[] = $this->createSupportsDenormalizationMethod($modelFqdn);
            $methods[] = $this->createSupportsNormalizationMethod($modelFqdn);
            $methods[] = $this->createDenormalizeMethod($modelFqdn, $context, $class->getProperties());
            $methods[] = $this->createNormalizeMethod($modelFqdn, $context, $class->getProperties());

            $normalizerClass = $this->createNormalizerClass(
                $class->getName().'Normalizer',
                $methods
            );
            $classes[] = $normalizerClass->name;

            $namespace = new Stmt\Namespace_(new Name($schema->getNamespace()."\\Normalizer"), [
                new Stmt\Use_([new Stmt\UseUse(new Name('Joli\Jane\Runtime\Reference'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Exception\InvalidArgumentException'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\DenormalizerInterface'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait'))]),
                new Stmt\Use_([new Stmt\UseUse(new Name('Symfony\Component\Serializer\Normalizer\NormalizerInterface'))]),
                $normalizerClass
            ]);
            $files[]   = new File($schema->getDirectory().'/Normalizer/'.$class->getName().'Normalizer.php', $namespace, self::FILE_TYPE_NORMALIZER);
        }

        $files[] = new File(
            $schema->getDirectory().'/Normalizer/NormalizerFactory.php',
            new Stmt\Namespace_(new Name($schema->getNamespace()."\\Normalizer"), [
                $this->createNormalizerFactoryClass($classes)
            ]),
            self::FILE_TYPE_NORMALIZER
        );

        return $files;
    }
public function generate ( $ schema , $ className , Context $ context ) { $ files = [ ] ; $ classes = [ ] ; foreach ( $ schema -> getClasses ( ) as $ class ) { $ methods = [ ] ; $ modelFqdn = $ schema -> getNamespace ( ) . "\\Model\\" . $ class -> getName ( ) ; $ methods [ ] = $ this -> createSupportsDenormalizationMethod ( $ modelFqdn ) ; $ methods [ ] = $ this -> createSupportsNormalizationMethod ( $ modelFqdn ) ; $ methods [ ] = $ this -> createDenormalizeMethod ( $ modelFqdn , $ context , $ class -> getProperties ( ) ) ; $ methods [ ] = $ this -> createNormalizeMethod ( $ modelFqdn , $ context , $ class -> getProperties ( ) ) ; $ normalizerClass = $ this -> createNormalizerClass ( $ class -> getName ( ) . 'Normalizer' , $ methods ) ; $ classes [ ] = $ normalizerClass -> name ; $ namespace = new Stmt \ Namespace_ ( new Name ( $ schema -> getNamespace ( ) . "\\Normalizer" ) , [ new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Joli\Jane\Runtime\Reference' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Exception\InvalidArgumentException' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Normalizer\DenormalizerInterface' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait' ) ) ] ) , new Stmt \ Use_ ( [ new Stmt \ UseUse ( new Name ( 'Symfony\Component\Serializer\Normalizer\NormalizerInterface' ) ) ] ) , $ normalizerClass ] ) ; $ files [ ] = new File ( $ schema -> getDirectory ( ) . '/Normalizer/' . $ class -> getName ( ) . 'Normalizer.php' , $ namespace , self :: FILE_TYPE_NORMALIZER ) ; } $ files [ ] = new File ( $ schema -> getDirectory ( ) . '/Normalizer/NormalizerFactory.php' , new Stmt \ Namespace_ ( new Name ( $ schema -> getNamespace ( ) . "\\Normalizer" ) , [ $ this -> createNormalizerFactoryClass ( $ classes ) ] ) , self :: FILE_TYPE_NORMALIZER ) ; return $ files ; }
Generate a set of files given a schema

@param Schema  $schema    Schema to generate from
@param string  $className Class to generate
@param Context $context   Context for generation

@return File[]
Generate a set of files given a schema