85 lines
2.9 KiB
PHP
85 lines
2.9 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Enum\{CardBusEnum, SlotKeyEnum};
|
|
use App\Entity\{Brand, Gpu, GpuCore};
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Symfony\Component\Form\
|
|
{AbstractType, Extension\Core\Type\EnumType, FormBuilderInterface};
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use UnitEnum;
|
|
|
|
class GpuType extends AbstractType {
|
|
use BrandCategoryTrait;
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
$builder
|
|
->add('gpuBrand', EntityType::class, [
|
|
'class' => Brand::class,
|
|
'query_builder' => self::filterBrands('gpu_core'),
|
|
])
|
|
->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'),
|
|
'placeholder' => 'Unknown',
|
|
'empty_data' => NULL,
|
|
'required' => FALSE,
|
|
])
|
|
->add('boardBrand', EntityType::class, [
|
|
'class' => Brand::class,
|
|
'query_builder' => self::filterBrands('graphics_card'),
|
|
'empty_data' => NULL,
|
|
'placeholder' => 'Unknown',
|
|
'required' => FALSE,
|
|
])
|
|
->add('alternateModelName')
|
|
->add('cardKey', EnumType::class, [
|
|
'class' => SlotKeyEnum::class,
|
|
'choices' => SlotKeyEnum::getGroups(),
|
|
'choice_label' => fn(UnitEnum $choice): string => $choice->value,
|
|
])
|
|
->add('busInterface', EnumType::class, [
|
|
'class' => CardBusEnum::class,
|
|
'choices' => CardBusEnum::getGroups(),
|
|
'choice_label' => fn(UnitEnum $choice): string => $choice->value,
|
|
])
|
|
->add('slotSpan')
|
|
->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)', 'empty_data' => '0'])
|
|
->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,
|
|
]);
|
|
}
|
|
}
|