wol-soft/php-json-schema-model-generator

View on GitHub
src/SchemaProcessor/PostProcessor/PopulatePostProcessor.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types = 1);

namespace PHPModelGenerator\SchemaProcessor\PostProcessor;

use PHPModelGenerator\Model\GeneratorConfiguration;
use PHPModelGenerator\Model\Schema;
use PHPModelGenerator\SchemaProcessor\Hook\SchemaHookResolver;

/**
 * Class PopulatePostProcessor
 *
 * @package PHPModelGenerator\SchemaProcessor\PostProcessor
 */
class PopulatePostProcessor extends PostProcessor
{
    public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
    {
        $schema->addMethod(
            'populate',
            new RenderedMethod(
                $schema,
                $generatorConfiguration,
                'Populate.phptpl',
                [
                    'schemaHookResolver' => new SchemaHookResolver($schema),
                    'true' => true,
                ],
            )
        );
    }
}