src/Entity/ProductoParametros.php line 33

  1. <?php
  2. namespace App\Entity;
  3. use Ramsey\Uuid\Uuid;
  4. use App\Trait\UuidTrait;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\Put;
  7. use ApiPlatform\Metadata\Post;
  8. use ApiPlatform\Metadata\Patch;
  9. use ApiPlatform\Metadata\Delete;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use ApiPlatform\Metadata\ApiProperty;
  12. use ApiPlatform\Metadata\ApiResource;
  13. use ApiPlatform\Metadata\GetCollection;
  14. use App\State\ProductoParametrosStateProcessor;
  15. use App\Repository\ProductoParametrosRepository;
  16. use Hautelook\AliceBundle\Functional\TestBundle\Entity\Prod;
  17. use Symfony\Component\Serializer\Annotation\Groups;
  18. #[ORM\Entity(repositoryClassProductoParametrosRepository::class)]
  19. #[ApiResource(
  20.     operations: [
  21.         new GetCollection(uriTemplate'productoParametros'paginationEnabledfalse),
  22.         new Post(uriTemplate'productoParametros'validationContext: ['groups' => ['Default''productoParametros:create']], denormalizationContext: ['groups' => ['productoParametros:create']], processorProductoParametrosStateProcessor::class),
  23.         new Get(uriTemplate'productoParametros/{uuid}'),
  24.         new Put(uriTemplate'productoParametros/{uuid}'denormalizationContext: ['groups' => ['productoParametros:update''uuid']]),
  25.         new Patch(uriTemplate'productoParametros/{uuid}'denormalizationContext: ['groups' => ['productoParametros:update''uuid']]),
  26.         new Delete(uriTemplate'productoParametros/{uuid}'),
  27.     ],
  28.     normalizationContext: ['groups' => ['productoParametros:read''uuid']],
  29. )]
  30. class ProductoParametros
  31. {
  32.     use UuidTrait;
  33.     #[Groups(['productoParametros:read'])]
  34.     #[ORM\ManyToOne]
  35.     #[ORM\JoinColumn(nullablefalse)]
  36.     private ?Empresa $empresa null;
  37.     
  38.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  39.     #[ORM\ManyToOne]
  40.     #[ORM\JoinColumn(nullablefalse)]
  41.     #[ApiProperty(readableLinkfalsewritableLinkfalse)]
  42.     private ?Fase $fase null;
  43.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  44.     #[ORM\Column(length255nullabletrue)]
  45.     private ?float $valMin null;
  46.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  47.     #[ORM\Column(length255nullabletrue)]
  48.     private ?float $valMax null;
  49.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  50.     #[ORM\Column(length255nullabletrue)]
  51.     private ?float $peso null;
  52.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  53.     #[ORM\Column(nullabletrue)]
  54.     private ?bool $isDefecto null;
  55.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  56.     #[ORM\Column(nullabletrue)]
  57.     private ?bool $isDiscriminante null;
  58.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  59.     #[ORM\Column(nullabletrue)]
  60.     private ?bool $isModEscala null;
  61.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update','producto:read''producto:create','producto:update'])]
  62.     #[ORM\Column(nullabletrue)]
  63.     private array $escala = [];
  64.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update''producto:read'])]
  65.     #[ORM\ManyToOne(inversedBy'parametros')]
  66.     #[ORM\JoinColumn(nullablefalse)]
  67.     private ?Producto $producto null;
  68.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update''producto:read''producto:create''producto:update'])]
  69.     #[ORM\ManyToOne]
  70.     #[ORM\JoinColumn(nullablefalse)]
  71.     #[ApiProperty(readableLinkfalsewritableLinkfalse)]
  72.     private ?Parametro $parametro null;
  73.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update''producto:read''producto:create''producto:update'])]
  74.     #[ORM\Column(nullabletrue)]
  75.     private ?bool $isActivo null;
  76.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update''producto:read''producto:create''producto:update'])]
  77.     #[ORM\Column(length3nullabletrue)]
  78.     private ?string $ordenFase null;
  79.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update''producto:read''producto:create''producto:update'])]
  80.     #[ORM\Column(length3nullabletrue)]
  81.     private ?string $ordenParametro null;
  82.     #[Groups(['productoParametros:read''productoParametros:create''productoParametros:update''producto:read''producto:create''producto:update'])]
  83.     #[ORM\Column(length255nullabletrue)]
  84.     private ?string $hook null;
  85.     public function __construct()
  86.     {
  87.         $this->uuid Uuid::uuid4()->toString();
  88.     }
  89.     public function cloneParametro(Producto $newProductoProductoParametros $productoParametros)
  90.     {
  91.         $clone = new ProductoParametros();
  92.         $clone->setEmpresa($productoParametros->getEmpresa());
  93.         $clone->setFase($productoParametros->getFase());
  94.         $clone->setValMin($productoParametros->getValMin());
  95.         $clone->setValMax($productoParametros->getValMax());
  96.         $clone->setPeso($productoParametros->getPeso());
  97.         $clone->setIsDefecto($productoParametros->isIsDefecto());
  98.         $clone->setIsDiscriminante($productoParametros->isIsDiscriminante());
  99.         $clone->setIsModEscala($productoParametros->isIsModEscala());
  100.         $clone->setEscala($productoParametros->getEscala());
  101.         $clone->setProducto($newProducto);
  102.         $clone->setParametro($productoParametros->getParametro());
  103.         $clone->setIsActivo($productoParametros->isIsActivo());
  104.         $clone->setOrdenFase($productoParametros->getOrdenFase());
  105.         $clone->setOrdenParametro($productoParametros->getOrdenParametro());
  106.         $clone->setHook($productoParametros->getHook());
  107.         return $clone;
  108.     }
  109.     public function getEmpresa(): ?Empresa
  110.     {
  111.         return $this->empresa;
  112.     }
  113.     public function setEmpresa(?Empresa $empresa): self
  114.     {
  115.         $this->empresa $empresa;
  116.         return $this;
  117.     }
  118.     public function getFase(): ?Fase
  119.     {
  120.         return $this->fase;
  121.     }
  122.     public function setFase(?Fase $fase): self
  123.     {
  124.         $this->fase $fase;
  125.         return $this;
  126.     }
  127.     public function getValMin(): ?float
  128.     {
  129.         return $this->valMin;
  130.     }
  131.     public function setValMin(?float $valMin): self
  132.     {
  133.         $this->valMin $valMin;
  134.         return $this;
  135.     }
  136.     public function getValMax(): ?float
  137.     {
  138.         return $this->valMax;
  139.     }
  140.     public function setValMax(?float $valMax): self
  141.     {
  142.         $this->valMax $valMax;
  143.         return $this;
  144.     }
  145.     public function getPeso(): ?float
  146.     {
  147.         return $this->peso;
  148.     }
  149.     public function setPeso(?float $peso): self
  150.     {
  151.         $this->peso $peso;
  152.         return $this;
  153.     }
  154.     public function isIsDefecto(): ?bool
  155.     {
  156.         return $this->isDefecto;
  157.     }
  158.     public function setIsDefecto(?bool $isDefecto): self
  159.     {
  160.         $this->isDefecto $isDefecto;
  161.         return $this;
  162.     }
  163.     public function isIsDiscriminante(): ?bool
  164.     {
  165.         return $this->isDiscriminante;
  166.     }
  167.     public function setIsDiscriminante(?bool $isDiscriminante): self
  168.     {
  169.         $this->isDiscriminante $isDiscriminante;
  170.         return $this;
  171.     }
  172.     public function isIsModEscala(): ?bool
  173.     {
  174.         return $this->isModEscala;
  175.     }
  176.     public function setIsModEscala(?bool $isModEscala): self
  177.     {
  178.         $this->isModEscala $isModEscala;
  179.         return $this;
  180.     }
  181.     public function getEscala(): array
  182.     {
  183.         return $this->escala;
  184.     }
  185.     public function setEscala(?array $escala): self
  186.     {
  187.         $this->escala $escala;
  188.         return $this;
  189.     }
  190.     public function getProducto(): ?Producto
  191.     {
  192.         return $this->producto;
  193.     }
  194.     public function setProducto(?Producto $producto): self
  195.     {
  196.         $this->producto $producto;
  197.         return $this;
  198.     }
  199.     public function getParametro(): ?Parametro
  200.     {
  201.         return $this->parametro;
  202.     }
  203.     public function setParametro(?Parametro $parametro): self
  204.     {
  205.         $this->parametro $parametro;
  206.         return $this;
  207.     }
  208.     public function isIsActivo(): ?bool
  209.     {
  210.         return $this->isActivo;
  211.     }
  212.     public function setIsActivo(?bool $isActivo): self
  213.     {
  214.         $this->isActivo $isActivo;
  215.         return $this;
  216.     }
  217.     public function getOrdenFase(): ?string
  218.     {
  219.         return $this->ordenFase;
  220.     }
  221.     public function setOrdenFase(?string $ordenFase): self
  222.     {
  223.         $this->ordenFase $ordenFase;
  224.         return $this;
  225.     }
  226.     public function getOrdenParametro(): ?string
  227.     {
  228.         return $this->ordenParametro;
  229.     }
  230.     public function setOrdenParametro(?string $ordenParametro): self
  231.     {
  232.         $this->ordenParametro $ordenParametro;
  233.         return $this;
  234.     }
  235.     public function getHook(): ?string
  236.     {
  237.         return $this->hook;
  238.     }
  239.     public function setHook(?string $hook): self
  240.     {
  241.         $this->hook $hook;
  242.         return $this;
  243.     }
  244. }