<?php


namespace AutoAdmin\Bundle\Seo\Schema;


use AutoAdmin\Bundle\Content\Context\ContentContext;
use AutoAdmin\Bundle\Seo\Schema\Model\Schema;

class SchemaManager
{
    /**
     * @var array<SchemaBuilderInterface>
     */
    private array $builders;

    public function __construct(array $builders = [])
    {
        $this->builders = $builders;
    }

    public function build(ContentContext $contentContext): void
    {
        $schema = $contentContext->getSchema() ?: new Schema();

        /** @var SchemaBuilderInterface $builder */
        foreach ($this->builders as $builder) {
            $builder->build($schema);
        }

        $contentContext->setSchema($schema);
    }
}