瀏覽代碼

[translatable] allow any type of field to be translated

Gediminas Morkevicius 14 年之前
父節點
當前提交
b9c834a407
共有 2 個文件被更改,包括 0 次插入56 次删除
  1. 0 28
      lib/Gedmo/Translatable/Mapping/Driver/Annotation.php
  2. 0 28
      lib/Gedmo/Translatable/Mapping/Driver/Yaml.php

+ 0 - 28
lib/Gedmo/Translatable/Mapping/Driver/Annotation.php

@@ -43,18 +43,6 @@ class Annotation implements Driver
      */
     const ANNOTATION_LANGUAGE = 'Gedmo\Translatable\Mapping\Language';
     
-    /**
-     * List of types which are valid for translation,
-     * this property is public and you can add some
-     * other types in case it needs translation
-     * 
-     * @var array
-     */
-    protected $validTypes = array(
-        'string',
-        'text'
-    );
-    
     /**
      * {@inheritDoc}
      */
@@ -93,9 +81,6 @@ class Annotation implements Driver
                 if (!$meta->hasField($field)) {
                     throw new InvalidMappingException("Unable to find translatable [{$field}] as mapped property in entity - {$meta->name}");
                 }
-                if (!$this->isValidField($meta, $field)) {
-                    throw new InvalidMappingException("Translatable field - [{$field}] type is not valid and must be 'string' or 'text' in class - {$meta->name}");
-                }
                 // fields cannot be overrided and throws mapping exception
                 $config['fields'][] = $field;
             }
@@ -115,17 +100,4 @@ class Annotation implements Driver
             }
         }
     }
-    
-    /**
-     * Checks if $field type is valid as Translatable field
-     * 
-     * @param ClassMetadata $meta
-     * @param string $field
-     * @return boolean
-     */
-    protected function isValidField(ClassMetadata $meta, $field)
-    {
-        $mapping = $meta->getFieldMapping($field);
-        return $mapping && in_array($mapping['type'], $this->validTypes);
-    }
 }

+ 0 - 28
lib/Gedmo/Translatable/Mapping/Driver/Yaml.php

@@ -27,18 +27,6 @@ class Yaml extends File implements Driver
      */
     protected $_extension = '.dcm.yml';
     
-    /**
-     * List of types which are valid for translation,
-     * this property is public and you can add some
-     * other types in case it needs translation
-     * 
-     * @var array
-     */
-    protected $validTypes = array(
-        'string',
-        'text'
-    );
-    
     /**
      * {@inheritDoc}
      */
@@ -70,9 +58,6 @@ class Yaml extends File implements Driver
             foreach ($mapping['fields'] as $field => $fieldMapping) {
                 if (isset($fieldMapping['gedmo'])) {
                     if (in_array('translatable', $fieldMapping['gedmo'])) {
-                        if (!$this->isValidField($meta, $field)) {
-                            throw new InvalidMappingException("Translatable field - [{$field}] type is not valid and must be 'string' or 'text' in class - {$meta->name}");
-                        }
                         // fields cannot be overrided and throws mapping exception
                         $config['fields'][] = $field;
                     }
@@ -88,17 +73,4 @@ class Yaml extends File implements Driver
     {
         return \Symfony\Component\Yaml\Yaml::load($file);
     }
-    
-    /**
-     * Checks if $field type is valid as Translatable field
-     * 
-     * @param ClassMetadata $meta
-     * @param string $field
-     * @return boolean
-     */
-    protected function isValidField(ClassMetadata $meta, $field)
-    {
-        $mapping = $meta->getFieldMapping($field);
-        return $mapping && in_array($mapping['type'], $this->validTypes);
-    }
 }