55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Enum\CpuArchitecture;
|
|
use App\Repository\CpuRepository;
|
|
use Doctrine\Common\Collections\{ArrayCollection, Collection};
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Table('cpu', schema: 'collection')]
|
|
#[ORM\Entity(repositoryClass: CpuRepository::class)]
|
|
class Cpu {
|
|
use GetSet;
|
|
use CpuBase;
|
|
|
|
#[ORM\Column('id', type: 'integer', nullable: FALSE)]
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
|
private int $id;
|
|
|
|
/**
|
|
* @var Collection<int, Socket>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Socket::class, inversedBy: 'cpus', fetch: 'LAZY')]
|
|
#[ORM\JoinTable('collection.cpu_socket_link')]
|
|
#[ORM\JoinColumn('cpu_id', referencedColumnName: 'id')]
|
|
#[ORM\InverseJoinColumn('socket_id', referencedColumnName: 'id')]
|
|
#[ORM\OrderBy(['name' => 'asc'])]
|
|
private Collection $sockets;
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
public function __construct()
|
|
{
|
|
$this->sockets = new ArrayCollection();
|
|
}
|
|
|
|
public function addSocket(Socket $socket): self
|
|
{
|
|
if ( ! $this->sockets->contains($socket))
|
|
{
|
|
$this->sockets->add($socket);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeSocket(Socket $socket): self
|
|
{
|
|
$this->sockets->removeElement($socket);
|
|
|
|
return $this;
|
|
}
|
|
}
|