collection-crud/src/Form/GpuType.php

72 lines
2.9 KiB
PHP

<?php declare(strict_types=1);
namespace App\Form;
use App\Entity\{Brand, Gpu, GpuCore};
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
use Symfony\Component\OptionsResolver\OptionsResolver;
class GpuType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$brandQueryBuilder = static fn (EntityRepository $e) => $e->createQueryBuilder('b')->orderBy('b.name', 'ASC');
$builder
->add('gpuBrand', EntityType::class, [
'class' => Brand::class,
'query_builder' => $brandQueryBuilder,
])
->add('modelName')
->add('gpuCore', EntityType::class, [
'class' => GpuCore::class,
'query_builder' => static fn (EntityRepository $e) => $e->createQueryBuilder('gc')->orderBy('gc.brand', 'ASC')->orderBy('gc.name', 'ASC'),
])
->add('boardBrand', EntityType::class, [
'class' => Brand::class,
'query_builder' => $brandQueryBuilder,
'empty_data' => NULL,
'placeholder' => 'Unknown',
'required' => false,
])
->add('alternateModelName')
->add('cardKey')
->add('busInterface')
->add('slotWidth')
->add('molexPower', null, ['label' => 'Molex Power Connectors'])
->add('pcie6power', null, ['label' => 'PCIe 6-pin Power Connectors'])
->add('pcie8power', null, ['label' => 'PCIe 8-pin Power Connectors'])
->add('tdp', null, ['label' => 'TDP (Watts)'])
->add('baseClock', null, ['label' => 'GPU Base Clock (MHz)'])
->add('boostClock', null, ['label' => 'GPU Boost Clock (MHz)'])
->add('memoryClock', null, ['label' => 'Memory Speed (MHz)'])
->add('memorySize', null, ['label' => 'Memory Size (MB)'])
->add('memoryBus', null, ['label' => 'Memory Bus Size (bits)'])
->add('memoryType')
->add('shadingUnits')
->add('tmus', null, ['label' => 'TMUs'])
->add('rops', null, ['label' => 'ROPs'])
->add('computeUnits')
->add('l1cache', null, ['label' => 'L1 Cache'])
->add('l2cache', null, ['label' => 'L2 Cache'])
->add('directXSupport', null, ['label' => 'DirectX Support'])
->add('openGLSupport', null, ['label' => 'OpenGL Support'])
->add('openCLSupport', null, ['label' => 'OpenCL Support'])
->add('vulkanSupport')
->add('shaderModel')
->add('link')
->add('count')
->add('acquired')
->add('notes');
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Gpu::class,
]);
}
}