Browse Source

translation entity mapped supperclass

gediminasm 14 năm trước cách đây
mục cha
commit
3a5ea89c8e

+ 2 - 152
lib/DoctrineExtensions/Translatable/Entity/Translation.php

@@ -10,159 +10,9 @@ namespace DoctrineExtensions\Translatable\Entity;
  * })
  * @Entity(repositoryClass="DoctrineExtensions\Translatable\Repository\TranslationRepository")
  */
-class Translation
+class Translation extends TranslationTemplate
 {
     /**
-     * @var integer $id
-     *
-     * @Column(name="id", type="integer")
-     * @Id
-     * @GeneratedValue(strategy="IDENTITY")
+     * All required columns are mapped through inhered superclass
      */
-    private $id;
-
-    /**
-     * @var string $locale
-     *
-     * @Column(name="locale", type="string", length=8)
-     */
-    private $locale;
-
-    /**
-     * @var string $entity
-     *
-     * @Column(name="entity", type="string", length=255)
-     */
-    private $entity;
-
-    /**
-     * @var string $field
-     *
-     * @Column(name="field", type="string", length=32)
-     */
-    private $field;
-
-    /**
-     * @var string $foreignKey
-     *
-     * @Column(name="foreign_key", type="string", length="64")
-     */
-    private $foreignKey;
-
-    /**
-     * @var text $content
-     *
-     * @Column(name="content", type="text", nullable=true)
-     */
-    private $content;
-    
-    /**
-     * Get id
-     *
-     * @return integer $id
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * Set locale
-     *
-     * @param string $locale
-     */
-    public function setLocale($locale)
-    {
-        $this->locale = $locale;
-    }
-
-    /**
-     * Get locale
-     *
-     * @return string $locale
-     */
-    public function getLocale()
-    {
-        return $this->locale;
-    }
-
-    /**
-     * Set field
-     *
-     * @param string $field
-     */
-    public function setField($field)
-    {
-        $this->field = $field;
-    }
-
-    /**
-     * Get field
-     *
-     * @return string $field
-     */
-    public function getField()
-    {
-        return $this->field;
-    }
-
-    /**
-     * Set entity
-     *
-     * @param string $entity
-     */
-    public function setEntity($entity)
-    {
-        $this->entity = $entity;
-    }
-
-    /**
-     * Get entity
-     *
-     * @return string $entity
-     */
-    public function getEntity()
-    {
-        return $this->entity;
-    }
-    
-    /**
-     * Set foreignKey
-     *
-     * @param string $foreignKey
-     */
-    public function setForeignKey($foreignKey)
-    {
-        $this->foreignKey = $foreignKey;
-    }
-
-    /**
-     * Get foreignKey
-     *
-     * @return string $foreignKey
-     */
-    public function getForeignKey()
-    {
-        return $this->foreignKey;
-    }
-    
-    /**
-     * Set content
-     *
-     * @param text $content
-     */
-    public function setContent($content)
-    {
-        $this->content = $content;
-    }
-
-    /**
-     * Get content
-     *
-     * @return text $content
-     */
-    public function getContent()
-    {
-        return $this->content;
-    }
 }

+ 165 - 0
lib/DoctrineExtensions/Translatable/Entity/TranslationTemplate.php

@@ -0,0 +1,165 @@
+<?php
+
+namespace DoctrineExtensions\Translatable\Entity;
+
+/**
+* DoctrineExtensions\Translatable\Entity\TranslationTemplate
+*
+* @MappedSuperclass
+*/
+class TranslationTemplate
+{
+    /**
+     * @var integer $id
+     *
+     * @Column(name="id", type="integer")
+     * @Id
+     * @GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string $locale
+     *
+     * @Column(name="locale", type="string", length=8)
+     */
+    private $locale;
+
+    /**
+     * @var string $entity
+     *
+     * @Column(name="entity", type="string", length=255)
+     */
+    private $entity;
+
+    /**
+     * @var string $field
+     *
+     * @Column(name="field", type="string", length=32)
+     */
+    private $field;
+
+    /**
+     * @var string $foreignKey
+     *
+     * @Column(name="foreign_key", type="string", length="64")
+     */
+    private $foreignKey;
+
+    /**
+     * @var text $content
+     *
+     * @Column(name="content", type="text", nullable=true)
+     */
+    private $content;
+    
+    /**
+     * Get id
+     *
+     * @return integer $id
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set locale
+     *
+     * @param string $locale
+     */
+    public function setLocale($locale)
+    {
+        $this->locale = $locale;
+    }
+
+    /**
+     * Get locale
+     *
+     * @return string $locale
+     */
+    public function getLocale()
+    {
+        return $this->locale;
+    }
+
+    /**
+     * Set field
+     *
+     * @param string $field
+     */
+    public function setField($field)
+    {
+        $this->field = $field;
+    }
+
+    /**
+     * Get field
+     *
+     * @return string $field
+     */
+    public function getField()
+    {
+        return $this->field;
+    }
+
+    /**
+     * Set entity
+     *
+     * @param string $entity
+     */
+    public function setEntity($entity)
+    {
+        $this->entity = $entity;
+    }
+
+    /**
+     * Get entity
+     *
+     * @return string $entity
+     */
+    public function getEntity()
+    {
+        return $this->entity;
+    }
+    
+    /**
+     * Set foreignKey
+     *
+     * @param string $foreignKey
+     */
+    public function setForeignKey($foreignKey)
+    {
+        $this->foreignKey = $foreignKey;
+    }
+
+    /**
+     * Get foreignKey
+     *
+     * @return string $foreignKey
+     */
+    public function getForeignKey()
+    {
+        return $this->foreignKey;
+    }
+    
+    /**
+     * Set content
+     *
+     * @param text $content
+     */
+    public function setContent($content)
+    {
+        $this->content = $content;
+    }
+
+    /**
+     * Get content
+     *
+     * @return text $content
+     */
+    public function getContent()
+    {
+        return $this->content;
+    }
+}

+ 4 - 44
tests/DoctrineExtensions/Translatable/Fixture/PersonTranslation.php

@@ -2,55 +2,15 @@
 
 namespace Translatable\Fixture;
 
+use DoctrineExtensions\Translatable\Entity\TranslationTemplate;
+
 /**
  * @Table(name="person_translations", indexes={
  *      @index(name="person_translation_idx", columns={"locale", "entity", "foreign_key", "field"})
  * })
  * @Entity(repositoryClass="DoctrineExtensions\Translatable\Repository\TranslationRepository")
  */
-class PersonTranslation
+class PersonTranslation extends TranslationTemplate
 {
-    /**
-     * @var integer $id
-     *
-     * @Column(name="id", type="integer")
-     * @Id
-     * @GeneratedValue(strategy="IDENTITY")
-     */
-    private $id;
-
-    /**
-     * @var string $locale
-     *
-     * @Column(name="locale", type="string", length=8)
-     */
-    private $locale;
-
-    /**
-     * @var string $entity
-     *
-     * @Column(name="entity", type="string", length=255)
-     */
-    private $entity;
-
-    /**
-     * @var string $field
-     *
-     * @Column(name="field", type="string", length=32)
-     */
-    private $field;
-
-    /**
-     * @var string $foreignKey
-     *
-     * @Column(name="foreign_key", type="string", length="64")
-     */
-    private $foreignKey;
-
-    /**
-     * @var text $content
-     *
-     * @Column(name="content", type="text", nullable=true)
-     */
-    private $content;
+    
 }