src/Entity/ContenidoTranslation.php line 28
- <?php
- namespace App\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\DBAL\Types\Types;
- use Doctrine\ORM\Mapping as ORM;
- // use Knp\DoctrineBehaviors\Model as ORMBehaviors;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Symfony\Component\Validator\Constraints as Assert;
- use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
- use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait;
- use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
- use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
- use Symfony\Component\String\Slugger\AsciiSlugger;
- /**
- * ContenidoTranslation
- *
- * @ORM\Entity
- * @ORM\InheritanceType("SINGLE_TABLE")
- * @ORM\DiscriminatorColumn(name="tipo", type="string")
- * @ORM\DiscriminatorMap( {"pagina" = "PaginaTranslation", "home" = "HomeTranslation", "contenido" = "ContenidoTranslation", "servicio" = "ContenidoServicioTranslation"} )
- * @ORM\Table(name="contenido_translation")
- */
- class ContenidoTranslation implements TranslationInterface, SluggableInterface
- {
- use TranslationTrait;
- use SluggableTrait;
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @var string
- *
- * Gedmo\Slug(fields={"titulo","translatable"}, unique=true)
- * ORM\Column(name="slug", type="string", length=255)
- */
- //protected $slug;
- /**
- * @var string
- *
- * @ORM\Column(name="titulo", type="string", length=255)
- * @Assert\NotBlank()
- */
- protected $titulo;
- /**
- * @var string
- *
- * @ORM\Column(name="texto", type="text", nullable=true)
- */
- protected $texto;
- /**
- * @var string
- *
- * @ORM\Column(name="intro", type="text", nullable=true)
- */
- protected $intro;
- /**
- * @var string
- *
- * @ORM\Column(name="meta_title", type="string", length=255, nullable=true)
- */
- protected $metaTitle;
- /**
- * @var string
- *
- * @ORM\Column(name="meta_description", type="text", nullable=true)
- */
- protected $metaDescription;
- /**
- * @var string
- *
- * @ORM\Column(name="meta_keywords", type="text", nullable=true)
- */
- protected $metaKeywords;
- /**
- * @var string
- *
- * @ORM\Column(name="meta_robots", type="string", length=255, nullable=true)
- */
- protected $metaRobots;
- /**
- * @var string
- *
- * @ORM\Column(name="canonical", type="string", length=255, nullable=true)
- */
- protected $canonical;
- /**
- * @var string
- *
- * @ORM\Column(name="config", type="json", nullable=true)
- */
- protected $textoExtra;
- /**
- * @var string
- *
- * @ORM\ManyToOne(targetEntity="Imagen", cascade={"persist"})
- */
- protected $imagenCabecera;
- protected $tipo;
- public function __construct()
- {
- $this->bloques = new ArrayCollection();
- }
- public function __toString()
- {
- return "[".$this->locale."]-".$this->getSlug();
- }
- public function getSlug(): string
- {
- if (!$this->slug)
- return "na";
- return $this->slug;
- }
- public function getSluggableFields(): array
- {
- return ['titulo'];
- }
- public function generateSlugValue($values): string
- {
- // $values[] = $this->getTranslatable()->getId();
- $sluggableText = implode('-', $values);
- $unicodeString = (new AsciiSlugger())->slug($sluggableText, $this->getSlugDelimiter());
- return strtolower($unicodeString->toString());
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set titulo
- *
- * @param string $titulo
- * @return ContenidoTranslation
- */
- public function setTitulo($titulo)
- {
- $this->titulo = $titulo;
- return $this;
- }
- /**
- * Get titulo
- *
- * @return string
- */
- public function getTitulo()
- {
- return $this->titulo;
- }
- /**
- * Set slug
- *
- * @param string $slug
- * @return ContenidoTranslation
- */
- public function setSlug($slug=null): void
- {
- $this->slug = $slug;
- // return $this;
- }
- /**
- * Get slug
- *
- * @return string
- */
- /*public function getSlug()
- {
- return $this->slug;
- }*/
- /**
- * Set texto
- *
- * @param string $texto
- * @return ContenidoTranslation
- */
- public function setTexto($texto)
- {
- $this->texto = $texto;
- return $this;
- }
- /**
- * Get texto
- *
- * @return string
- */
- public function getTexto()
- {
- return $this->texto;
- }
- /**
- * Set intro
- *
- * @param string $intro
- * @return ContenidoTranslation
- */
- public function setIntro($intro)
- {
- $this->intro = $intro;
- return $this;
- }
- /**
- * Get intro
- *
- * @return string
- */
- public function getIntro()
- {
- return $this->intro;
- }
- /**
- * Set metaTitle
- *
- * @param string $metaTitle
- * @return BaseHtml
- */
- public function setMetaTitle($metaTitle)
- {
- $this->metaTitle = $metaTitle;
- return $this;
- }
- /**
- * Get metaTitle
- *
- * @return string
- */
- public function getMetaTitle()
- {
- return $this->metaTitle;
- }
- /**
- * Set metaDescription
- *
- * @param string $metaDescription
- * @return ContenidoTranslation
- */
- public function setMetaDescription($metaDescription)
- {
- $this->metaDescription = $metaDescription;
- return $this;
- }
- /**
- * Get metaDescription
- *
- * @return string
- */
- public function getMetaDescription()
- {
- return $this->metaDescription;
- }
- /**
- * Set metaKeywords
- *
- * @param string $metaKeywords
- * @return ContenidoTranslation
- */
- public function setMetaKeywords($metaKeywords)
- {
- $this->metaKeywords = $metaKeywords;
- return $this;
- }
- /**
- * Get metaKeywords
- *
- * @return string
- */
- public function getMetaKeywords()
- {
- return $this->metaKeywords;
- }
- /*public function getTipo()
- {
- return $this->tipo;
- }*/
- public static function getTipo()
- {
- $c = get_called_class();
- return $c::TIPO;
- }
- public function getMetaRobots(): ?string
- {
- return $this->metaRobots;
- }
- public function setMetaRobots(?string $metaRobots): self
- {
- $this->metaRobots = $metaRobots;
- return $this;
- }
- public function getCanonical(): ?string
- {
- return $this->canonical;
- }
- public function setCanonical(?string $canonical): self
- {
- $this->canonical = $canonical;
- return $this;
- }
- public function getTextoExtra(): array
- {
- return $this->textoExtra;
- }
- public function setTextoExtra(?array $textoExtra): self
- {
- $this->textoExtra = $textoExtra;
- return $this;
- }
- public function getImagenCabecera(): ?Imagen
- {
- return $this->imagenCabecera;
- }
- public function setImagenCabecera(?Imagen $imagenCabecera): self
- {
- $this->imagenCabecera = $imagenCabecera;
- return $this;
- }
- }