src/Entity/Divisa.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  9.  /**
  10.  * Divisa
  11.  *
  12.  * @ORM\Table(name="divisa")
  13.  * @ORM\Entity(repositoryClass="App\Repository\DivisaRepository")
  14.  */
  15. class Divisa implements TranslatableInterface
  16. {
  17.     use TranslatableTrait;
  18.    /**
  19.      * @var integer
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="shortName", type="string", length=255)
  30.      */
  31.     private $shortName;
  32.     
  33. //    /**
  34. //     * @var string
  35. //     *
  36. //     * @ORM\Column(name="altBanner", type="string", length=255, nullable=true)
  37. //     *
  38. //     */
  39. //    private $altBanner;
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="altFlag", type="string", length=255, nullable=true)
  44.      *
  45.      */
  46.     private $altFlag;
  47.     /**
  48.      * @var integer
  49.      *
  50.      * @ORM\Column(name="peso", type="integer", length=255)
  51.      */
  52.     private $peso=0;
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(name="simbolo", type="string", length=5, nullable=true)
  57.      */
  58.     private $simbolo;
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="title", type="string", length=255)
  63.      */
  64.     private $title;
  65.     /**
  66.      * @var boolean
  67.      *
  68.      * @ORM\Column(name="bloqueado", type="boolean")
  69.      */
  70.     private $bloqueado=0;
  71.     /**
  72.      * @var boolean
  73.      *
  74.      * @ORM\Column(name="maestro", type="boolean")
  75. */
  76.     private $maestro=0;
  77.     /**
  78.      * @var boolean
  79.      *
  80.      * @ORM\Column(name="virtual", type="boolean")
  81.      */
  82.     private $virtual=0;
  83.     /**
  84.      * @var boolean
  85.      *
  86.      * @ORM\Column(name="visible", type="boolean")
  87.      */
  88.     private $visible=0;
  89.     /**
  90.      * @ORM\OneToMany(targetEntity="Cotizaciones", mappedBy="shortName", cascade={"remove"})
  91.      * @ORM\OrderBy({"dia" = "DESC"})
  92.      */
  93.     private $cotizaciones;
  94.     /**
  95.      * @var string
  96.      *
  97.      * @ORM\Column(name="redondeoMinimo", type="float")
  98.      */
  99.     private $redondeoMinimo=1;
  100.     /**
  101.      * @var string
  102.      *
  103.      * @ORM\Column(name="numDecimales", type="integer")
  104.      */
  105.     private $numDecimales=0;
  106.     /**
  107.      * @var string
  108.      *
  109.      * @ORM\Column(name="url_organismo_oficial", type="string", nullable=true)
  110.      */
  111.     private $urlOrganismoOficial=NULL;
  112.     /**
  113.      * @var string
  114.      *
  115.      * @ORM\ManyToOne(targetEntity="Imagen") 
  116.      */
  117.     protected $imagen
  118.     /**
  119.      * @var string
  120.      *
  121.      * @ORM\ManyToOne(targetEntity="Imagen") 
  122.      */
  123.     protected $banner
  124.     /**
  125.      * @ORM\OneToMany(targetEntity="DivisaConversion", mappedBy="divisaOrigen", orphanRemoval=true)
  126.      */
  127.     private $origenConversiones;
  128.     /**
  129.      * @ORM\OneToMany(targetEntity="DivisaConversion", mappedBy="divisaDestino", orphanRemoval=true)
  130.      */
  131.     private $destinoConversiones;
  132.     /**
  133.      * @var integer
  134.      *
  135.      * @ORM\Column(name="compraMinima", type="integer", length=255)
  136.      */
  137.     private $compraMinima=0;
  138.     /**
  139.      * @ORM\ManyToMany(targetEntity="Cupon", mappedBy="divisas")
  140.      *
  141.      */
  142.     protected $cupones;
  143.     
  144.     
  145.     private $translations2;
  146.     
  147.     public function __call($method$args)
  148.     {
  149.         if (!method_exists(self::getTranslationEntityClass(), $method)) {
  150.             $method 'get'ucfirst($method);
  151.         }
  152.         return $this->proxyCurrentLocaleTranslation($method$args);
  153.     }
  154.     
  155.     public function __toString() {
  156.         return $this->shortName;
  157.     }
  158.     public function __construct() {
  159.         $this->traducciones = new ArrayCollection();
  160.         $this->cotizaciones = new ArrayCollection();
  161.         $this->origenConversiones = new ArrayCollection();
  162.         $this->destinoConversiones = new ArrayCollection();
  163.         $this->cupones = new ArrayCollection();
  164.     }
  165.     public function addCotizacion(Cotizaciones $cotizaciones)
  166.     {
  167.         $this->cotizaciones[] = $cotizaciones;
  168.     }
  169.     public function getCotizaciones()
  170.     {
  171.         return $this->cotizaciones;
  172.     }
  173.     /**
  174.      * Get id
  175.      *
  176.      * @return integer
  177.      */
  178.     public function getId()
  179.     {
  180.         return $this->id;
  181.     }
  182. //    /**
  183. //     * Get altBanner
  184. //     *
  185. //     * @return string
  186. //     */
  187. //    public function getAltBanner(){
  188. //        return $this->altBanner;
  189. //    }
  190. //
  191. //    /**
  192. //     * Set altBanner
  193. //     * @param string $altBanner
  194. //     * @return Divisa
  195. //     */
  196. //
  197. //    public function setAltBAnner($altBAnner){
  198. //
  199. //        $this->altBanner = $altBAnner;
  200. //
  201. //        return $this;
  202. //
  203. //    }
  204.     /**
  205.      * Get altFlag
  206.      *
  207.      * @return string
  208.      */
  209.     public function getAltFlag(){
  210.         return $this->altFlag;
  211.     }
  212.     /**
  213.      * Set altFlag
  214.      * @param string $altFlag
  215.      * @return Divisa
  216.      */
  217.     public function setAltFlag($altFlag){
  218.         $this->altFlag $altFlag;
  219.         return $this;
  220.     }
  221.     /**
  222.      * Set shortName
  223.      *
  224.      * @param string $shortName
  225.      * @return Divisa
  226.      */
  227.     public function setShortName($shortName)
  228.     {
  229.         $this->shortName $shortName;
  230.         return $this;
  231.     }
  232.     /**
  233.      * Get shortName
  234.      *
  235.      * @return string
  236.      */
  237.     public function getShortName()
  238.     {
  239.         return $this->shortName;
  240.     }
  241.     /**
  242.      * Set simbolo
  243.      *
  244.      * @param string $simbolo
  245.      * @return Divisa
  246.      */
  247.     public function setSimbolo($simbolo)
  248.     {
  249.         $this->simbolo $simbolo;
  250.         return $this;
  251.     }
  252.     /**
  253.      * Get maestro
  254.      *
  255.      * @return string
  256.      */
  257.     public function getMaestro()
  258.     {
  259.         return $this->maestro;
  260.     }
  261.     /**
  262.      * Set maestro
  263.      *
  264.      * @param boolean $maestro
  265.      * @return Divisa
  266.      */
  267.     public function setMaestro($maestro)
  268.     {
  269.         $this->maestro $maestro;
  270.         return $this;
  271.     }
  272.     /**
  273.      * Get simbolo
  274.      *
  275.      * @return string
  276.      */
  277.     public function getSimbolo()
  278.     {
  279.         return $this->simbolo;
  280.     }
  281.     /**
  282.      * Set title
  283.      *
  284.      * @param string $title
  285.      * @return Divisa
  286.      */
  287.     public function setTitle($title)
  288.     {
  289.         $this->title $title;
  290.         return $this;
  291.     }
  292.     /**
  293.      * Get title
  294.      *
  295.      * @return string
  296.      */
  297.     public function getTitle()
  298.     {
  299.         return $this->title;
  300.     }
  301.     /**
  302.      * Set redondeoMinimo
  303.      *
  304.      * @param int $redondeoMinimo
  305.      * @return Divisa
  306.      */
  307.     public function setRedondeoMinimo($redondeoMinimo)
  308.     {
  309.         $this->redondeoMinimo $redondeoMinimo;
  310.         return $this;
  311.     }
  312.     /**
  313.     * Get redondeoMinimo
  314.     *
  315.     * @return int
  316.     */
  317.     public function getRedondeoMinimo()
  318.     {
  319.         return $this->redondeoMinimo;
  320.     }
  321.     /**
  322.      * Set redondeoMinimo
  323.      *
  324.      * @param bool $redondeoMinimo
  325.      * @return Divisa
  326.      */
  327.     public function setBloqueado($bloqueado)
  328.     {
  329.         $this->bloqueado $bloqueado;
  330.         return $this;
  331.     }
  332.     /**
  333.     * Get bloqueado
  334.     *
  335.     * @return bool
  336.     */
  337.     public function getBloqueado()
  338.     {
  339.         return $this->bloqueado;
  340.     }
  341.     /**
  342.      * Set redondeoMinimo
  343.      *
  344.      * @param bool $redondeoMinimo
  345.      * @return Divisa
  346.      */
  347.     public function setVirtual($virtual)
  348.     {
  349.         $this->virtual $virtual;
  350.         return $this;
  351.     }
  352.     /**
  353.     * Get virtual
  354.     *
  355.     * @return bool
  356.     */
  357.     public function getVirtual()
  358.     {
  359.         return $this->virtual;
  360.     }
  361.     /**
  362.      * Set antigua
  363.      *
  364.      * @param bool $visible
  365.      * @return Divisa
  366.      */
  367.     public function setVisible($visible)
  368.     {
  369.         $this->visible $visible;
  370.         return $this;
  371.     }
  372.     /**
  373.     * Get urlOrganismoOficial
  374.     *
  375.     * @return bool
  376.     */
  377.     public function getUrlOrganismoOficial()
  378.     {
  379.         return $this->urlOrganismoOficial;
  380.     }
  381.     /**
  382.      * Set urlOrganismoOficial
  383.      *
  384.      * @param bool $urlOrganismoOficial
  385.      * @return Divisa
  386.      */
  387.     public function setUrlOrganismoOficial($urlOrganismoOficial)
  388.     {
  389.         $this->urlOrganismoOficial $urlOrganismoOficial;
  390.         return $this;
  391.     }
  392.     /**
  393.     * Get visble
  394.     *
  395.     * @return bool
  396.     */
  397.     public function getVisible()
  398.     {
  399.         return $this->visible;
  400.     }
  401.    public function jsonSerialize()
  402.     {
  403.         return array(
  404.             'id' => $this->id,
  405.             'shortName'=> $this->shortName,
  406.             'nombreIngles'=> $this->nombreIngles,
  407.             'nombreEspanol'=> $this->nombreEspanol,
  408.             'redondeoMinimo' => $this->redondeoMinimo,
  409.             'cotizaciones' =>json_encode($this->cotizaciones),
  410.         );
  411.     }
  412.     /**
  413.      * Set traducciones
  414.      *
  415.      * @param ArrayColection $divisa
  416.      * @return Divisa
  417.      */
  418.     public function setTraducciones($traducciones)
  419.     {
  420.         $this->traducciones=$traducciones;
  421.         return $this;
  422.     }
  423.     /**
  424.      * add traducciones
  425.      *
  426.      * @param DivisaIdioma $oficina
  427.      * @return Divisa
  428.      */
  429.     public function addTraduccion(DivisaIdioma $traduccion)
  430.     {
  431.         $this->traducciones[]=$traduccion;
  432.         return $this;
  433.     }
  434.     /**
  435.      * add traducciones
  436.      *
  437.      * @param DivisaIdioma $oficina
  438.      * @return Divisa
  439.      */
  440.     public function removeTraduccion(DivisaIdioma $traduccion)
  441.     {
  442.         return $this;
  443.     }
  444.     /**
  445.      * Get traducciones
  446.      *
  447.      * @return ArrayCollection
  448.      */
  449.     public function getTraducciones()
  450.     {
  451.         return $this->traducciones;
  452.     }
  453.     /**
  454.      * Get traducciones
  455.      *
  456.      * @return traducciones
  457.      */
  458.    /* public function getSlug($locale)
  459.     {
  460.         foreach($this->traducciones as $td){
  461.              if($td->getIdioma()->getUrl()==$locale){
  462.                 return $td->getSlug();
  463.             }
  464.         }
  465.         return false;
  466.     }*/
  467.     
  468.     public function getSlug($locale=null)
  469.     {
  470.         if (null === $locale) {
  471.             $locale $this->getCurrentLocale();
  472.         }
  473.             
  474.         return $this->translate($locale)->getSlug();
  475.     }
  476.     /**
  477.      * Get traducciones
  478.      *
  479.      * @return traducciones
  480.      */
  481.     public function getNombreLocal($locale)
  482.     {
  483.         foreach($this->traducciones as $td){
  484.              if($td->getIdioma()->getUrl()==$locale){
  485.                 return $td->getNombre();
  486.             }
  487.         }
  488.         return false;
  489.     }
  490.     /**
  491.      * Set peso
  492.      *
  493.      * @param integer $peso
  494.      * @return Divisa
  495.      */
  496.     public function setPeso($peso)
  497.     {
  498.         $this->peso $peso;
  499.         return $this;
  500.     }
  501.     /**
  502.      * Get peso
  503.      *
  504.      * @return integer
  505.      */
  506.     public function getPeso()
  507.     {
  508.         return $this->peso;
  509.     }
  510.     /**
  511.      * Set numDecimales
  512.      *
  513.      * @param integer $numDecimales
  514.      * @return Divisa
  515.      */
  516.     public function setNumDecimales($numDecimales)
  517.     {
  518.         $this->numDecimales $numDecimales;
  519.         return $this;
  520.     }
  521.     /**
  522.      * Get numDecimales
  523.      *
  524.      * @return integer
  525.      */
  526.     public function getNumDecimales()
  527.     {
  528.         return $this->numDecimales;
  529.     }
  530.     /**
  531.      * Set compraMinima
  532.      *
  533.      * @param integer $compraMinima
  534.      * @return Divisa
  535.      */
  536.     public function setCompraMinima($compraMinima)
  537.     {
  538.         $this->compraMinima $compraMinima;
  539.         return $this;
  540.     }
  541.     /**
  542.      * Get compraMinima
  543.      *
  544.      * @return integer
  545.      */
  546.     public function getCompraMinima()
  547.     {
  548.         return $this->compraMinima;
  549.     }
  550.     public function isBloqueado(): ?bool
  551.     {
  552.         return $this->bloqueado;
  553.     }
  554.     public function isMaestro(): ?bool
  555.     {
  556.         return $this->maestro;
  557.     }
  558.     public function isVirtual(): ?bool
  559.     {
  560.         return $this->virtual;
  561.     }
  562.     public function isVisible(): ?bool
  563.     {
  564.         return $this->visible;
  565.     }
  566.     public function addCotizacione(Cotizaciones $cotizacione): self
  567.     {
  568.         if (!$this->cotizaciones->contains($cotizacione)) {
  569.             $this->cotizaciones->add($cotizacione);
  570.             $cotizacione->setShortName($this);
  571.         }
  572.         return $this;
  573.     }
  574.     public function removeCotizacione(Cotizaciones $cotizacione): self
  575.     {
  576.         if ($this->cotizaciones->removeElement($cotizacione)) {
  577.             // set the owning side to null (unless already changed)
  578.             if ($cotizacione->getShortName() === $this) {
  579.                 $cotizacione->setShortName(null);
  580.             }
  581.         }
  582.         return $this;
  583.     }
  584.     public function getImagen(): ?Imagen
  585.     {
  586.         return $this->imagen;
  587.     }
  588.     public function setImagen(?Imagen $imagen): self
  589.     {
  590.         $this->imagen $imagen;
  591.         return $this;
  592.     }
  593.     public function getBanner(): ?Imagen
  594.     {
  595.         return $this->banner;
  596.     }
  597.     public function setBanner(?Imagen $banner): self
  598.     {
  599.         $this->banner $banner;
  600.         return $this;
  601.     }
  602.     /**
  603.      * @return Collection<int, DivisaConversion>
  604.      */
  605.     public function getOrigenConversiones(): Collection
  606.     {
  607.         return $this->origenConversiones;
  608.     }
  609.     public function addOrigenConversione(DivisaConversion $origenConversione): self
  610.     {
  611.         if (!$this->origenConversiones->contains($origenConversione)) {
  612.             $this->origenConversiones->add($origenConversione);
  613.             $origenConversione->setDivisaOrigen($this);
  614.         }
  615.         return $this;
  616.     }
  617.     public function removeOrigenConversione(DivisaConversion $origenConversione): self
  618.     {
  619.         if ($this->origenConversiones->removeElement($origenConversione)) {
  620.             // set the owning side to null (unless already changed)
  621.             if ($origenConversione->getDivisaOrigen() === $this) {
  622.                 $origenConversione->setDivisaOrigen(null);
  623.             }
  624.         }
  625.         return $this;
  626.     }
  627.     /**
  628.      * @return Collection<int, DivisaConversion>
  629.      */
  630.     public function getDestinoConversiones(): Collection
  631.     {
  632.         return $this->destinoConversiones;
  633.     }
  634.     public function addDestinoConversione(DivisaConversion $destinoConversione): self
  635.     {
  636.         if (!$this->destinoConversiones->contains($destinoConversione)) {
  637.             $this->destinoConversiones->add($destinoConversione);
  638.             $destinoConversione->setDivisaDestino($this);
  639.         }
  640.         return $this;
  641.     }
  642.     public function removeDestinoConversione(DivisaConversion $destinoConversione): self
  643.     {
  644.         if ($this->destinoConversiones->removeElement($destinoConversione)) {
  645.             // set the owning side to null (unless already changed)
  646.             if ($destinoConversione->getDivisaDestino() === $this) {
  647.                 $destinoConversione->setDivisaDestino(null);
  648.             }
  649.         }
  650.         return $this;
  651.     }
  652.     
  653.     public function getCupones()
  654.     {
  655.         return $this->cupones;
  656.     }
  657.     public function getNombre(): ?string
  658.     {
  659.         return $this->translate(nullfalse)->getNombre();
  660.     }
  661. }