<commit_before><?php

namespace Opifer\EavBundle\ValueProvider;

use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\FormBuilderInterface;
use Opifer\EavBundle\Form\Transformer\CollectionToObjectTransformer;

class RadioValueProvider extends AbstractValueProvider implements ValueProviderInterface
{
    /** @var string */
    protected $optionClass;

    /**
     * Constructor
     *
     * @param string $optionClass
     */
    public function __construct($optionClass)
    {
        $this->optionClass = $optionClass;
    }

    /**
     * {@inheritDoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $attributeId = $options['attribute']->getId();
        $transformer = new CollectionToObjectTransformer();
        
        $builder->add(
            $builder->create('options', 'entity', [
                'label'         => $options['attribute']->getDisplayName(),
                'multiple'      => false,   // Only allow single selection
                'expanded'      => true,   // Render as radio buttons
                'property'      => 'displayName', // Assuming that the entity has a "name" property
                'class'         => $this->optionClass,
                'query_builder' => function (EntityRepository $optionRepository) use ($attributeId) {
                    return $optionRepository->createQueryBuilder('o')
                        ->add('orderBy', 'o.sort ASC')
                        ->innerJoin('o.attribute', 'a')
                        ->where('a.id = :attributeId')
                        ->setParameter('attributeId', $attributeId)
                    ;<commit_msg>Set data_class on RadioValueProvider<commit_after><?php

namespace Opifer\EavBundle\ValueProvider;

use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\FormBuilderInterface;
use Opifer\EavBundle\Form\Transformer\CollectionToObjectTransformer;

class RadioValueProvider extends AbstractValueProvider implements ValueProviderInterface
{
    /** @var string */
    protected $optionClass;

    /**
     * Constructor
     *
     * @param string $optionClass
     */
    public function __construct($optionClass)
    {
        $this->optionClass = $optionClass;
    }

    /**
     * {@inheritDoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $attributeId = $options['attribute']->getId();
        $transformer = new CollectionToObjectTransformer();
        
        $builder->add(
            $builder->create('options', 'entity', [
                'label'         => $options['attribute']->getDisplayName(),
                'multiple'      => false,   // Only allow single selection
                'expanded'      => true,   // Render as radio buttons
                'property'      => 'displayName', // Assuming that the entity has a "name" property
                'class'         => $this->optionClass,
                'data_class'    => $this->optionClass,
                'query_builder' => function (EntityRepository $optionRepository) use ($attributeId) {
                    return $optionRepository->createQueryBuilder('o')
                        ->add('orderBy', 'o.sort ASC')
                        ->innerJoin('o.attribute', 'a')
                        ->where('a.id = :attributeId')
                        ->setParameter('attributeId', $attributeId)
                    ;
{'fraction_non_alphanumeric': 0.1190893169877408, 'fraction_numerical': 0.0, 'mean_word_length': 2.079065588499551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4114966', 'n_tokens_mistral': 862, 'n_tokens_neox': 835, 'n_words': 177}