collection-crud/src/Form/GpuType.php

85 lines
2.9 KiB
PHP
Raw Normal View History

2022-10-07 16:04:34 -04:00
<?php declare(strict_types=1);
namespace App\Form;
2022-11-17 15:32:57 -05:00
use App\Enum\{CardBus, SlotKey};
2022-10-07 16:04:34 -04:00
use App\Entity\{Brand, Gpu, GpuCore};
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
2022-10-13 22:26:33 -04:00
use Symfony\Component\Form\
{AbstractType, Extension\Core\Type\EnumType, FormBuilderInterface};
2022-10-07 16:04:34 -04:00
use Symfony\Component\OptionsResolver\OptionsResolver;
use UnitEnum;
2022-10-07 16:04:34 -04:00
class GpuType extends AbstractType {
2022-10-20 11:07:27 -04:00
use BrandCategoryTrait;
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('gpuBrand', EntityType::class, [
'class' => Brand::class,
2022-10-20 11:07:27 -04:00
'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'),
2022-10-13 22:26:33 -04:00
'placeholder' => 'Unknown',
'empty_data' => NULL,
'required' => FALSE,
])
->add('boardBrand', EntityType::class, [
'class' => Brand::class,
2022-10-20 11:07:27 -04:00
'query_builder' => self::filterBrands('graphics_card'),
'empty_data' => NULL,
2022-10-07 22:00:14 -04:00
'placeholder' => 'Unknown',
'required' => FALSE,
])
->add('alternateModelName')
->add('cardKey', EnumType::class, [
2022-11-17 15:32:57 -05:00
'class' => SlotKey::class,
'choices' => SlotKey::getGroups(),
'choice_label' => fn(UnitEnum $choice): string => $choice->value,
])
->add('busInterface', EnumType::class, [
2022-11-17 15:32:57 -05:00
'class' => CardBus::class,
'choices' => CardBus::getGroups(),
'choice_label' => fn(UnitEnum $choice): string => $choice->value,
2022-10-13 22:26:33 -04:00
])
->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');
}
2022-10-07 16:04:34 -04:00
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Gpu::class,
]);
}
2022-10-07 16:04:34 -04:00
}