src/Entity/ProductoParametros.php line 34

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