src/Entity/ContenidoTranslation.php line 28

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. // use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
  11. use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait;
  12. use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
  13. use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
  14. use Symfony\Component\String\Slugger\AsciiSlugger;
  15. /**
  16.  * ContenidoTranslation
  17.  *
  18.  * @ORM\Entity
  19.  * @ORM\InheritanceType("SINGLE_TABLE")
  20.  * @ORM\DiscriminatorColumn(name="tipo", type="string")
  21.  * @ORM\DiscriminatorMap( {"pagina" = "PaginaTranslation", "home" = "HomeTranslation", "contenido" = "ContenidoTranslation", "servicio" = "ContenidoServicioTranslation"} )
  22.  * @ORM\Table(name="contenido_translation")
  23.  */
  24. class ContenidoTranslation implements TranslationInterfaceSluggableInterface
  25. {
  26.     use TranslationTrait;
  27.     use SluggableTrait;
  28.     
  29.      /**
  30.      * @var integer
  31.      *
  32.      * @ORM\Column(name="id", type="integer")
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue(strategy="AUTO")
  35.      */
  36.     protected $id;
  37.     
  38.     /**
  39.      * @var string
  40.      *
  41.      * Gedmo\Slug(fields={"titulo","translatable"}, unique=true)
  42.      * ORM\Column(name="slug", type="string", length=255)
  43.      */ 
  44.     //protected $slug;   
  45.     
  46.       
  47.     
  48.     /**
  49.      * @var string
  50.      *
  51.      * @ORM\Column(name="titulo", type="string", length=255)
  52.      * @Assert\NotBlank()
  53.      */
  54.     protected $titulo;
  55.     /**
  56.      * @var string
  57.      *
  58.      * @ORM\Column(name="texto", type="text", nullable=true)
  59.      */
  60.     protected $texto;
  61.     
  62.     
  63.     /**
  64.      * @var string
  65.      *
  66.      * @ORM\Column(name="intro", type="text", nullable=true)
  67.      */
  68.     protected $intro;
  69.     
  70.     /**
  71.      * @var string
  72.      *
  73.      * @ORM\Column(name="meta_title", type="string", length=255, nullable=true)
  74.      */
  75.     protected $metaTitle;
  76.     /**
  77.      * @var string
  78.      *
  79.      * @ORM\Column(name="meta_description", type="text", nullable=true)
  80.      */
  81.     protected $metaDescription;
  82.     /**
  83.      * @var string
  84.      *
  85.      * @ORM\Column(name="meta_keywords", type="text", nullable=true)
  86.      */
  87.     protected $metaKeywords;
  88.     
  89.     /**
  90.      * @var string
  91.      *
  92.      * @ORM\Column(name="meta_robots", type="string", length=255, nullable=true)
  93.      */
  94.     protected $metaRobots;    
  95.     
  96.     /**
  97.      * @var string
  98.      *
  99.      * @ORM\Column(name="canonical", type="string", length=255, nullable=true)
  100.      */
  101.     protected $canonical;
  102.     
  103.     
  104.     /**
  105.      * @var string
  106.      *
  107.      * @ORM\Column(name="config", type="json", nullable=true)
  108.      */
  109.     protected $textoExtra;
  110.     
  111.     
  112.     /**
  113.      * @var string
  114.      *
  115.      * @ORM\ManyToOne(targetEntity="Imagen", cascade={"persist"}) 
  116.      */
  117.     protected $imagenCabecera;  
  118.     
  119.     
  120.     
  121.     protected $tipo;
  122.     public function __construct()
  123.     {
  124.         $this->bloques = new ArrayCollection();
  125.     }
  126.  
  127.     
  128.     public function __toString()
  129.     {
  130.         return "[".$this->locale."]-".$this->getSlug();
  131.     }
  132.     
  133.     
  134.     public function getSlug(): string
  135.     {
  136.         if (!$this->slug)
  137.             return "na";
  138.         return $this->slug;
  139.     }
  140.     
  141.     
  142.     public function getSluggableFields(): array
  143.     {
  144.         return ['titulo'];
  145.     }
  146.     
  147.     public function generateSlugValue($values): string
  148.     {
  149. //         $values[] = $this->getTranslatable()->getId();
  150.         
  151.         $sluggableText implode('-'$values);
  152.         
  153.         $unicodeString = (new AsciiSlugger())->slug($sluggableText$this->getSlugDelimiter());
  154.         return strtolower($unicodeString->toString());
  155.     }
  156.     
  157.     /**
  158.      * Get id
  159.      *
  160.      * @return integer 
  161.      */
  162.     public function getId()
  163.     {
  164.         return $this->id;
  165.     }       
  166.     
  167.  
  168.     /**
  169.      * Set titulo
  170.      *
  171.      * @param string $titulo
  172.      * @return ContenidoTranslation
  173.      */
  174.     public function setTitulo($titulo)
  175.     {
  176.         $this->titulo $titulo;
  177.     
  178.         return $this;
  179.     }
  180.     /**
  181.      * Get titulo
  182.      *
  183.      * @return string 
  184.      */
  185.     public function getTitulo()
  186.     {
  187.         return $this->titulo;
  188.     }
  189.     /**
  190.      * Set slug
  191.      *
  192.      * @param string $slug
  193.      * @return ContenidoTranslation
  194.      */
  195.     public function setSlug($slug=null): void
  196.     {
  197.         $this->slug $slug;
  198.     
  199. //         return $this;
  200.     }
  201.     /**
  202.      * Get slug
  203.      *
  204.      * @return string 
  205.      */
  206.     /*public function getSlug()
  207.     {
  208.         return $this->slug;
  209.     }*/
  210.     /**
  211.      * Set texto
  212.      *
  213.      * @param string $texto
  214.      * @return ContenidoTranslation
  215.      */
  216.     public function setTexto($texto)
  217.     {
  218.         $this->texto $texto;
  219.     
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get texto
  224.      *
  225.      * @return string 
  226.      */
  227.     public function getTexto()
  228.     {
  229.         return $this->texto;
  230.     }
  231.     
  232.     /**
  233.      * Set intro
  234.      *
  235.      * @param string $intro
  236.      * @return ContenidoTranslation
  237.      */
  238.     public function setIntro($intro)
  239.     {
  240.         $this->intro $intro;
  241.     
  242.         return $this;
  243.     }
  244.     /**
  245.      * Get intro
  246.      *
  247.      * @return string 
  248.      */
  249.     public function getIntro()
  250.     {
  251.         return $this->intro;
  252.     }    
  253.     
  254.     /**
  255.      * Set metaTitle
  256.      *
  257.      * @param string $metaTitle
  258.      * @return BaseHtml
  259.      */
  260.     public function setMetaTitle($metaTitle)
  261.     {
  262.         $this->metaTitle $metaTitle;
  263.     
  264.         return $this;
  265.     }
  266.     /**
  267.      * Get metaTitle
  268.      *
  269.      * @return string 
  270.      */
  271.     public function getMetaTitle()
  272.     {
  273.         return $this->metaTitle;
  274.     }
  275.     /**
  276.      * Set metaDescription
  277.      *
  278.      * @param string $metaDescription
  279.      * @return ContenidoTranslation
  280.      */
  281.     public function setMetaDescription($metaDescription)
  282.     {
  283.         $this->metaDescription $metaDescription;
  284.     
  285.         return $this;
  286.     }
  287.     /**
  288.      * Get metaDescription
  289.      *
  290.      * @return string 
  291.      */
  292.     public function getMetaDescription()
  293.     {
  294.         return $this->metaDescription;
  295.     }
  296.     /**
  297.      * Set metaKeywords
  298.      *
  299.      * @param string $metaKeywords
  300.      * @return ContenidoTranslation
  301.      */
  302.     public function setMetaKeywords($metaKeywords)
  303.     {
  304.         $this->metaKeywords $metaKeywords;
  305.     
  306.         return $this;
  307.     }
  308.     /**
  309.      * Get metaKeywords
  310.      *
  311.      * @return string 
  312.      */
  313.     public function getMetaKeywords()
  314.     {
  315.         return $this->metaKeywords;
  316.     }
  317.     
  318.     
  319.     
  320.     /*public function getTipo()    
  321.     {
  322.         return $this->tipo;
  323.     }*/
  324.     
  325.     public static function getTipo()
  326.     {
  327.         $c get_called_class();
  328.         return $c::TIPO;
  329.     }
  330.     public function getMetaRobots(): ?string
  331.     {
  332.         return $this->metaRobots;
  333.     }
  334.     public function setMetaRobots(?string $metaRobots): self
  335.     {
  336.         $this->metaRobots $metaRobots;
  337.         return $this;
  338.     }
  339.     public function getCanonical(): ?string
  340.     {
  341.         return $this->canonical;
  342.     }
  343.     public function setCanonical(?string $canonical): self
  344.     {
  345.         $this->canonical $canonical;
  346.         return $this;
  347.     }
  348.     public function getTextoExtra(): array
  349.     {
  350.         return $this->textoExtra;
  351.     }
  352.     public function setTextoExtra(?array $textoExtra): self
  353.     {
  354.         $this->textoExtra $textoExtra;
  355.         return $this;
  356.     }
  357.     public function getImagenCabecera(): ?Imagen
  358.     {
  359.         return $this->imagenCabecera;
  360.     }
  361.     public function setImagenCabecera(?Imagen $imagenCabecera): self
  362.     {
  363.         $this->imagenCabecera $imagenCabecera;
  364.         return $this;
  365.     }
  366.     
  367. }