<commit_before><?php

namespace Siriux\GalleryBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class ImageType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder
            ->add('gallery', 'entity', array(
                'class' => 'SiriuxGalleryBundle:Gallery',
                'empty_value' => '-- Choose a category --'))
            ->add('media', 'siriux_media_type')
        ;
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Siriux\GalleryBundle\Entity\Image',
        );
    }

    public function getName()
    {
        return 'siriux_image';<commit_msg>Restrict category selection to enabled ones.<commit_after><?php

namespace Siriux\GalleryBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Doctrine\ORM\EntityRepository;

class ImageType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $enabledGalleries = function(EntityRepository $er) {
                               return $er->createQueryBuilder('g')
                                    ->where('g.enabled = 1');
        };

        $builder
            ->add('gallery', 'entity', array(
                'class' => 'SiriuxGalleryBundle:Gallery',
                'empty_value' => '-- Choose a category --',
                'query_builder' => $enabledGalleries))
            ->add('media', 'siriux_media_type')
        ;
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Siriux\GalleryBundle\Entity\Image',
        );
    }

    public function getName()
    {
        return 'siriux_image';
{'fraction_non_alphanumeric': 0.11745334796926454, 'fraction_numerical': 0.0005488474204171241, 'mean_word_length': 2.2437722419928825, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6195250', 'n_tokens_mistral': 519, 'n_tokens_neox': 504, 'n_words': 99}