diff --git a/composer.lock b/composer.lock index e1fceef..0d7ba1c 100644 --- a/composer.lock +++ b/composer.lock @@ -1451,16 +1451,16 @@ }, { "name": "friendsofphp/proxy-manager-lts", - "version": "v1.0.12", + "version": "v1.0.13", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/proxy-manager-lts.git", - "reference": "8419f0158715b30d4b99a5bd37c6a39671994ad7" + "reference": "88354616f4cf4f6620910fd035e282173ba453e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/8419f0158715b30d4b99a5bd37c6a39671994ad7", - "reference": "8419f0158715b30d4b99a5bd37c6a39671994ad7", + "url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/88354616f4cf4f6620910fd035e282173ba453e8", + "reference": "88354616f4cf4f6620910fd035e282173ba453e8", "shasum": "" }, "require": { @@ -1517,7 +1517,7 @@ ], "support": { "issues": "https://github.com/FriendsOfPHP/proxy-manager-lts/issues", - "source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.12" + "source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.13" }, "funding": [ { @@ -1529,7 +1529,7 @@ "type": "tidelift" } ], - "time": "2022-05-05T09:31:05+00:00" + "time": "2022-10-17T19:48:16+00:00" }, { "name": "laminas/laminas-code", @@ -6472,12 +6472,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "1d3484a08d3875e28bc2ad66697b0947cd6a2d99" + "reference": "c8e297691dcc30deef58efddd6765c8b7821be56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1d3484a08d3875e28bc2ad66697b0947cd6a2d99", - "reference": "1d3484a08d3875e28bc2ad66697b0947cd6a2d99", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/c8e297691dcc30deef58efddd6765c8b7821be56", + "reference": "c8e297691dcc30deef58efddd6765c8b7821be56", "shasum": "" }, "conflict": { @@ -6616,7 +6616,7 @@ "gaoming13/wechat-php-sdk": "<=1.10.2", "genix/cms": "<=1.1.11", "getgrav/grav": "<1.7.34", - "getkirby/cms": "<3.5.8.1|>=3.6,<3.6.6.1|>=3.7,<3.7.4", + "getkirby/cms": "= 3.8.0|<3.5.8.2|>=3.6,<3.6.6.2|>=3.7,<3.7.5.1", "getkirby/panel": "<2.5.14", "getkirby/starterkit": "<=3.7.0.2", "gilacms/gila": "<=1.11.4", @@ -6731,7 +6731,7 @@ "openid/php-openid": "<2.3", "openmage/magento-lts": "<19.4.15|>=20,<20.0.13", "orchid/platform": ">=9,<9.4.4", - "oro/commerce": ">=5,<5.0.4", + "oro/commerce": ">=4.1,<5.0.6", "oro/crm": ">=1.7,<1.7.4|>=3.1,<4.1.17|>=4.2,<4.2.7", "oro/platform": ">=1.7,<1.7.4|>=3.1,<3.1.29|>=4.1,<4.1.17|>=4.2,<4.2.8", "packbackbooks/lti-1-3-php-library": "<5", @@ -6991,7 +6991,7 @@ "type": "tidelift" } ], - "time": "2022-10-13T20:04:41+00:00" + "time": "2022-10-18T22:04:50+00:00" }, { "name": "sebastian/cli-parser", diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml index 9a2dc4e..9f840a2 100644 --- a/config/packages/doctrine_migrations.yaml +++ b/config/packages/doctrine_migrations.yaml @@ -1,6 +1,4 @@ doctrine_migrations: migrations_paths: - - '%kernel.project_dir%/src/Migrations' - # namespace is arbitrary but should be different from App\Migrations - # as migrations classes should NOT be autoloaded - # namespace: DoctrineMigrations + 'App\Migrations': '%kernel.project_dir%/src/Migrations' + check_database_platform: true diff --git a/config/services.yaml b/config/services.yaml index da7e080..98c72d7 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -32,6 +32,3 @@ services: # App\Service\ExampleService: # arguments: # $someArgument: 'some_value' - _instanceof: - App\Types\AbstractEnumType: - tags: [ 'app.doctrine_enum_type' ] diff --git a/src/Entity/Brand.php b/src/Entity/Brand.php index eaaae06..71e8e04 100644 --- a/src/Entity/Brand.php +++ b/src/Entity/Brand.php @@ -2,12 +2,14 @@ namespace App\Entity; +use App\Repository\BrandRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; #[ORM\Table(name: 'brand', schema: 'collection')] -#[ORM\Entity] +#[ORM\Entity]//(repositoryClass: BrandRepository::class)] +#[ORM\UniqueConstraint(name: 'brand_unq', columns: ["name"])] class Brand { use GetSetTrait; diff --git a/src/Entity/Camera.php b/src/Entity/Camera.php index 899a2fb..9afd9b9 100644 --- a/src/Entity/Camera.php +++ b/src/Entity/Camera.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping as ORM; * Camera */ #[ORM\Table(name: 'camera', schema: 'collection')] -#[ORM\Index(columns: ['type_id'], name: 'IDX_747C826FC54C8C93')] #[ORM\Entity(repositoryClass: CameraRepository::class)] class Camera { diff --git a/src/Entity/CameraTrait.php b/src/Entity/CameraTrait.php index 689a722..9309ed0 100644 --- a/src/Entity/CameraTrait.php +++ b/src/Entity/CameraTrait.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping as ORM; */ trait CameraTrait { + use GetSetTrait; use PurchasePriceTrait; #[ORM\ManyToOne(targetEntity: 'CameraType')] @@ -52,165 +53,4 @@ trait CameraTrait #[ORM\Column(name: 'received', type: 'boolean', nullable: TRUE)] private ?bool $received = FALSE; - - public function getId(): int - { - return $this->id; - } - - public function setType(?CameraType $type = NULL): self - { - $this->type = $type; - - return $this; - } - - public function getType(): CameraType - { - return $this->type; - } - - public function setBrand(string $brand): self - { - $this->brand = $brand; - - return $this; - } - - public function getBrand(): string - { - return $this->brand; - } - - public function setMount(string $mount): self - { - $this->mount = $mount; - - return $this; - } - - public function getMount(): string - { - return $this->mount; - } - - public function setModel(string $model): self - { - $this->model = $model; - - return $this; - } - - public function getModel(): string - { - return $this->model; - } - - public function setIsDigital(bool $isDigital): self - { - $this->isDigital = $isDigital; - - return $this; - } - - public function getIsDigital(): bool - { - return $this->isDigital; - } - - public function setCropFactor(string $cropFactor): self - { - $this->cropFactor = $cropFactor; - - return $this; - } - - public function getCropFactor(): string - { - return $this->cropFactor; - } - - public function setIsWorking(bool $isWorking): self - { - $this->isWorking = $isWorking; - - return $this; - } - - public function getIsWorking(): bool - { - return $this->isWorking; - } - - public function setNotes(?string $notes): self - { - $this->notes = $notes; - - return $this; - } - - public function getNotes(): string - { - return $this->notes ?? ''; - } - - public function setSerial(string $serial): self - { - $this->serial = $serial; - - return $this; - } - - public function getSerial(): string - { - return $this->serial ?? ''; - } - - public function setFormerlyOwned(bool $formerlyOwned): self - { - $this->formerlyOwned = $formerlyOwned; - - return $this; - } - - public function getFormerlyOwned(): bool - { - return $this->formerlyOwned; - } - - public function setBatteryType(string $batteryType): self - { - $this->batteryType = $batteryType; - - return $this; - } - - public function getBatteryType(): string - { - return $this->batteryType ?? ''; - } - - public function setFilmFormat(string $filmFormat): self - { - $this->filmFormat = $filmFormat; - - return $this; - } - - public function getFilmFormat(): string - { - return $this->filmFormat ?? ''; - } - - public function setReceived(bool $received): self - { - $this->received = $received; - - return $this; - } - - public function getReceived(): bool - { - return $this->received; - } } diff --git a/src/Entity/Gpu.php b/src/Entity/Gpu.php index 9fbcd6d..924b2cf 100644 --- a/src/Entity/Gpu.php +++ b/src/Entity/Gpu.php @@ -40,40 +40,84 @@ class Gpu #[ORM\Column(name: 'alternate_model_name', nullable: TRUE)] private ?string $alternateModelName = ''; - #[ORM\Column(name: 'card_key', type: SlotKeyEnumType::NAME, nullable: TRUE, enumType: SlotKeyEnum::class)] + #[ORM\Column( + name: 'card_key', + type: 'string', + enumType: SlotKeyEnum::class, + options: array( + 'comment' => "The shape of the card connector", + 'default' => "PCIe x16" + ) + )] private SlotKeyEnum $cardKey = SlotKeyEnum::PCIE_X16; - #[ORM\Column(name: 'bus_interface', type: CardBusEnumType::NAME, nullable: TRUE, enumType: CardBusEnum::class)] + #[ORM\Column( + name: 'bus_interface', + type: 'string', + nullable: TRUE, + enumType: CardBusEnum::class, + options: array('comment' => "The type of electrical bus this card uses") + )] private ?CardBusEnum $busInterface; - #[ORM\Column(name: 'slot_width')] - private int $slotWidth = 1; + #[ORM\Column( + name: 'slot_span', + options: array( + 'comment' => "How many expansion slots the card occupies", + 'default' => 1, + ), + )] + private int $slotSpan = 1; - #[ORM\Column(name: 'molex_power')] + #[ORM\Column(name: 'molex_power', options: array('default' => 0))] private int $molexPower = 0; - #[ORM\Column(name: 'pcie_6_pin')] + #[ORM\Column(name: 'pcie_6_pin', options: array('default' => 0))] private int $pcie6power = 0; - #[ORM\Column(name: 'pcie_8_pin')] + #[ORM\Column(name: 'pcie_8_pin', options: array('default' => 0))] private int $pcie8power = 0; - #[ORM\Column(name: 'tdp', nullable: TRUE)] + #[ORM\Column( + name: 'tdp', + nullable: TRUE, + options: array('comment' => "Thermal Design Power (in Watts)") + )] private ?int $tdp = 0; - #[ORM\Column(name: 'base_clock', nullable: TRUE)] + #[ORM\Column( + name: 'base_clock', + nullable: TRUE, + options: array('comment' => "Base speed of the gpu core, in MHz") + )] private ?int $baseClock; - #[ORM\Column(name: 'boost_clock', nullable: TRUE)] + #[ORM\Column( + name: 'boost_clock', + nullable: TRUE, + options: array('comment' => "GPU core boost clock, in MHz") + )] private ?int $boostClock; - #[ORM\Column(name: 'memory_clock', nullable: TRUE)] + #[ORM\Column( + name: 'memory_clock', + nullable: TRUE, + options: array('comment' => "Clock speed of the VRAM, in MHz") + )] private ?int $memoryClock; - #[ORM\Column(name: 'memory_size', nullable: TRUE)] + #[ORM\Column( + name: 'memory_size', + nullable: TRUE, + options: array('comment' => 'VRAM size, in MiB') + )] private ?int $memorySize; - #[ORM\Column(name: 'memory_bus', nullable: TRUE)] + #[ORM\Column( + name: 'memory_bus', + nullable: TRUE, + options: array("comment" => 'The width of the memory bus in bits') + )] private ?int $memoryBus; #[ORM\Column(name: 'memory_type', nullable: TRUE)] @@ -112,13 +156,13 @@ class Gpu #[ORM\Column(name: 'shader_model', nullable: TRUE)] private ?string $shaderModel; - #[ORM\Column(name: 'link')] - private string $link; + #[ORM\Column(name: 'link', nullable: TRUE)] + private ?string $link; - #[ORM\Column(name: 'count', nullable: FALSE)] + #[ORM\Column(name: 'count', nullable: FALSE, options: array('default' => 1))] private int $count = 1; - #[ORM\Column(name: 'acquired')] + #[ORM\Column(name: 'acquired', nullable: FALSE, options: array('default' => true))] private bool $acquired; #[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)] diff --git a/src/Entity/GpuCore.php b/src/Entity/GpuCore.php index 60a80ff..5e6c2e9 100644 --- a/src/Entity/GpuCore.php +++ b/src/Entity/GpuCore.php @@ -18,7 +18,7 @@ class GpuCore implements Stringable #[ORM\ManyToOne(targetEntity: 'Brand')] #[ORM\OrderBy(['name' => 'asc'])] - #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')] + #[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id', nullable: FALSE)] private Brand $brand; #[ORM\Column(name: 'name')] @@ -27,16 +27,16 @@ class GpuCore implements Stringable #[ORM\Column(name: 'variant', nullable: TRUE)] private ?string $variant; - #[ORM\Column(name: 'generation_name')] + #[ORM\Column(name: 'generation_name', nullable: TRUE)] private string $generationName; #[ORM\Column(name: 'generation_link', nullable: TRUE)] private ?string $generationLink = ''; - #[ORM\Column(name: 'architecture')] + #[ORM\Column(name: 'architecture', nullable: TRUE)] private string $architecture; - #[ORM\Column(name: 'architecture_link')] + #[ORM\Column(name: 'architecture_link', nullable: TRUE)] private string $architectureLink; #[ORM\Column(name: 'process_node', nullable: TRUE)] diff --git a/src/Entity/PreviouslyOwnedCamera.php b/src/Entity/PreviouslyOwnedCamera.php index 4980ea2..80faf8b 100644 --- a/src/Entity/PreviouslyOwnedCamera.php +++ b/src/Entity/PreviouslyOwnedCamera.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping as ORM; * Camera.previouslyOwnedCamera */ #[ORM\Table(name: 'previously_owned_camera', schema: 'collection')] -#[ORM\Index(name: 'IDX_6EF94C6BC54C8C93', columns: ['type_id'])] #[ORM\Entity(repositoryClass: CameraRepository::class)] class PreviouslyOwnedCamera { diff --git a/src/Form/GpuType.php b/src/Form/GpuType.php index ae0c24b..e30c643 100644 --- a/src/Form/GpuType.php +++ b/src/Form/GpuType.php @@ -47,7 +47,7 @@ class GpuType extends AbstractType { 'choices' => CardBusEnum::getGroups(), 'choice_label' => fn(UnitEnum $choice): string => $choice->value, ]) - ->add('slotWidth') + ->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']) diff --git a/src/Kernel.php b/src/Kernel.php index ae1685b..8f044a9 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -11,15 +11,12 @@ namespace App; -use App\Types\AbstractEnumType; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -class Kernel extends BaseKernel implements CompilerPassInterface +class Kernel extends BaseKernel { use MicroKernelTrait; @@ -37,19 +34,4 @@ class Kernel extends BaseKernel implements CompilerPassInterface $routes->import('../config/{routes}/*.yaml'); $routes->import('../config/{routes}.yaml'); } - - public function process(ContainerBuilder $container) - { - $typesDefinition = []; - if ($container->hasParameter('doctrine.dbal.connection_factory.types')) { - $typesDefinition = $container->getParameter('doctrine.dbal.connection_factory.types'); - } - - $taggedEnums = $container->findTaggedServiceIds('app.doctrine_enum_type'); - - foreach ($taggedEnums as $enumType => $definition) { - $typesDefinition[$enumType::NAME] = ['class' => $enumType]; - } - $container->setParameter('doctrine.dbal.connection_factory.types', $typesDefinition); - } } diff --git a/src/Migrations/Version20221014203914.php b/src/Migrations/Version20221014203914.php new file mode 100644 index 0000000..3fdc57c --- /dev/null +++ b/src/Migrations/Version20221014203914.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE collection.gpu ALTER card_key TYPE character varying'); + $this->addSql('ALTER TABLE collection.gpu ALTER bus_interface TYPE character varying'); + } + + public function down(Schema $schema): void + { + } +} diff --git a/src/Migrations/Version20221014212753.php b/src/Migrations/Version20221014212753.php new file mode 100644 index 0000000..7327d37 --- /dev/null +++ b/src/Migrations/Version20221014212753.php @@ -0,0 +1,31 @@ +addSql('CREATE SCHEMA public'); + } +} diff --git a/src/Repository/BrandRepository.php b/src/Repository/BrandRepository.php index a51484c..f439a85 100644 --- a/src/Repository/BrandRepository.php +++ b/src/Repository/BrandRepository.php @@ -2,17 +2,10 @@ namespace App\Repository; -use App\Entity\Brand; -use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; -use Doctrine\Persistence\ManagerRegistry; - -class BrandRepository extends ServiceEntityRepository { - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, Brand::class); - } +class BrandRepository extends EntityRepository { public function filterByCategory(string $category): Query { $em = $this->getEntityManager(); diff --git a/src/Types/AbstractEnumType.php b/src/Types/AbstractEnumType.php deleted file mode 100644 index a593467..0000000 --- a/src/Types/AbstractEnumType.php +++ /dev/null @@ -1,44 +0,0 @@ -value; - } - - return $value; - } - - public function convertToPHPValue($value, AbstractPlatform $platform): mixed - { - if (false === enum_exists($this::getEnumsClass(), true)) - { - throw new \LogicException("This class should be an enum"); - } - - $enum = $this::getEnumsClass(); - - return $enum::from($value); - } - - abstract public static function getEnumsClass(): string; -} diff --git a/src/Types/BusInterface.php b/src/Types/BusInterface.php deleted file mode 100644 index 787810a..0000000 --- a/src/Types/BusInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -
diff --git a/templates/gpu/index.html.twig b/templates/gpu/index.html.twig index 7d37966..52fe73d 100644 --- a/templates/gpu/index.html.twig +++ b/templates/gpu/index.html.twig @@ -105,7 +105,7 @@ {{ gpu.alternateModelName }} {{ gpu.cardKey.value }} {{ gpu.busInterface.value }} - {{ gpu.slotWidth }} + {{ gpu.slotSpan }} {% if gpu.pcie6power > 0 or gpu.pcie8power > 0 %} {% if gpu.pcie6power > 0 %} diff --git a/templates/gpu/new.html.twig b/templates/gpu/new.html.twig index 14ed40b..e2373bd 100644 --- a/templates/gpu/new.html.twig +++ b/templates/gpu/new.html.twig @@ -32,7 +32,7 @@ {{ form_row(form.cardKey) }} {{ form_row(form.busInterface) }} - {{ form_row(form.slotWidth) }} + {{ form_row(form.slotSpan) }}
diff --git a/templates/gpu/show.html.twig b/templates/gpu/show.html.twig index bf9edba..447e3bc 100644 --- a/templates/gpu/show.html.twig +++ b/templates/gpu/show.html.twig @@ -49,8 +49,8 @@ {{ gpu.busInterface.value }} - SlotWidth - {{ gpu.slotWidth }} + slotSpan + {{ gpu.slotSpan }} MolexPower