collection-crud/src/Form/CpuType.php

105 lines
2.5 KiB
PHP
Raw Normal View History

2023-07-21 10:35:15 -04:00
<?php declare(strict_types=1);
2022-10-27 11:55:16 -04:00
namespace App\Form;
2023-07-21 10:35:15 -04:00
use App\Entity\{Brand, Cpu};
2022-11-17 15:32:57 -05:00
use App\Enum\CpuArchitecture;
2022-10-28 08:46:35 -04:00
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
2023-07-21 10:35:15 -04:00
use Symfony\Component\Form\Extension\Core\Type\{EnumType, UrlType};
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
2022-10-27 11:55:16 -04:00
use Symfony\Component\OptionsResolver\OptionsResolver;
2022-10-28 08:46:35 -04:00
use UnitEnum;
2022-10-27 11:55:16 -04:00
2022-10-28 08:46:35 -04:00
class CpuType extends AbstractType {
use BrandCategoryTrait;
2022-10-27 11:55:16 -04:00
2022-10-28 08:46:35 -04:00
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('architecture', EnumType::class, [
2022-11-17 15:32:57 -05:00
'class' => CpuArchitecture::class,
2023-07-21 10:35:15 -04:00
'choice_label' => static fn (UnitEnum $choice): string => $choice->value,
2022-11-17 15:32:57 -05:00
'choices' => CpuArchitecture::getGroups(),
2022-10-28 08:46:35 -04:00
])
->add('brand', EntityType::class, [
'class' => Brand::class,
'query_builder' => self::filterBrands('cpu'),
])
->add('sockets')
->add('productLine')
->add('model')
->add('partNumber')
->add('lotNumber')
->add('microArchitecture')
->add('codeName')
// Cache Stuff
2023-07-21 10:35:15 -04:00
->add('L1dCount', NULL, [
2022-10-28 08:46:35 -04:00
'label' => 'L1 Data Cache(s)',
])
2023-07-21 10:35:15 -04:00
->add('L1dSize', NULL, [
'label' => 'L1 Data Size KB',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L1dWay', NULL, [
'label' => 'L1 Data (x-way)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L1cCount', NULL, [
2022-10-28 08:46:35 -04:00
'label' => 'L1 Instruction Cache(s)',
])
2023-07-21 10:35:15 -04:00
->add('L1cSize', NULL, [
'label' => 'L1 Instruction Size KB',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L1cWay', NULL, [
'label' => 'L1 Instruction (x-way)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L1uCount', NULL, [
2022-10-28 08:46:35 -04:00
'label' => 'L1 Unified Cache(s)',
])
2023-07-21 10:35:15 -04:00
->add('L1uSize', NULL, [
'label' => 'L1 Unified Cache Size: KB',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L1uWay', NULL, [
'label' => 'L1 Unified (x-way)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L2Count', NULL, [
'label' => 'L2 Cache(s)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L2Size', NULL, [
'label' => 'L2 Cache Size KB (per unit)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L2Way', NULL, [
'label' => 'L2 Cache (x-way)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L3Count', NULL, [
'label' => 'L3 Cache(s)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L3Size', NULL, [
'label' => 'L3 Cache Size KB (per unit)',
2022-10-28 08:46:35 -04:00
])
2023-07-21 10:35:15 -04:00
->add('L3Way', NULL, [
'label' => 'L3 Cache (x-way)',
2022-10-28 08:46:35 -04:00
])
->add('baseSpeed')
->add('boostSpeed')
->add('cores')
->add('threads')
->add('igp')
->add('voltage')
->add('tdp')
->add('processNode')
->add('count')
->add('usable')
->add('received')
->add('link', UrlType::class)
2023-07-21 10:35:15 -04:00
->add('notes');
2022-10-28 08:46:35 -04:00
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Cpu::class,
]);
}
2022-10-27 11:55:16 -04:00
}