<?php


namespace AutoAdmin\Bundle\Seo\Schema;


use AutoAdmin\Bundle\Seo\Schema\Builder\SchemaBuilderInterface;
use AutoAdmin\Bundle\Seo\Schema\Model\SchemaStack;
use Traversable;

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

    public function __construct(Traversable $builders)
    {
        // "aa_seo.schema_builder"
        $this->builders = array_map([$this, 'add'], iterator_to_array($builders));
    }

    public function build(SchemaStack $stack): void
    {
        /** @var SchemaBuilderInterface $builder */
        foreach ($this->builders as $builder) {
            $builder->build($stack);
        }
    }

    protected function add(SchemaBuilderInterface $builder): SchemaBuilderInterface
    {
        return $builder;
    }
}
