Browse Source

Made all types extend Type again.

The previous change was too eager and broke both BC and several features in the
framework. Fixes #9216
Jose Lorenzo Rodriguez 9 years ago
parent
commit
3b341696e1

+ 2 - 14
src/Database/Type/BinaryType.php

@@ -17,6 +17,7 @@ namespace Cake\Database\Type;
 use Cake\Core\Exception\Exception;
 use Cake\Database\Driver;
 use Cake\Database\Driver\Sqlserver;
+use Cake\Database\Type;
 use Cake\Database\TypeInterface;
 use PDO;
 
@@ -25,7 +26,7 @@ use PDO;
  *
  * Use to convert binary data between PHP and the database types.
  */
-class BinaryType implements TypeInterface
+class BinaryType extends Type implements TypeInterface
 {
 
     /**
@@ -46,19 +47,6 @@ class BinaryType implements TypeInterface
     }
 
     /**
-     * Returns the base type name that this class is inheriting.
-     * This is useful when extending base type for adding extra functionality
-     * but still want the rest of the framework to use the same assumptions it would
-     * do about the base type it inherits from.
-     *
-     * @return string
-     */
-    public function getBaseType()
-    {
-        return $this->_name;
-    }
-
-    /**
      * Convert binary data into the database format.
      *
      * Binary data is not altered before being inserted into the database.

+ 2 - 14
src/Database/Type/BoolType.php

@@ -15,6 +15,7 @@
 namespace Cake\Database\Type;
 
 use Cake\Database\Driver;
+use Cake\Database\Type;
 use Cake\Database\TypeInterface;
 use InvalidArgumentException;
 use PDO;
@@ -24,7 +25,7 @@ use PDO;
  *
  * Use to convert bool data between PHP and the database types.
  */
-class BoolType implements TypeInterface
+class BoolType extends Type implements TypeInterface
 {
 
     /**
@@ -45,19 +46,6 @@ class BoolType implements TypeInterface
     }
 
     /**
-     * Returns the base type name that this class is inheriting.
-     * This is useful when extending base type for adding extra functionality
-     * but still want the rest of the framework to use the same assumptions it would
-     * do about the base type it inherits from.
-     *
-     * @return string
-     */
-    public function getBaseType()
-    {
-        return $this->_name;
-    }
-
-    /**
      * Convert bool data into the database format.
      *
      * @param mixed $value The value to convert.

+ 2 - 1
src/Database/Type/DateTimeType.php

@@ -15,6 +15,7 @@
 namespace Cake\Database\Type;
 
 use Cake\Database\Driver;
+use Cake\Database\Type;
 use Cake\Database\TypeInterface;
 use DateTimeInterface;
 use Exception;
@@ -26,7 +27,7 @@ use RuntimeException;
  *
  * Use to convert datetime instances to strings & back.
  */
-class DateTimeType implements TypeInterface
+class DateTimeType extends Type implements TypeInterface
 {
 
     /**

+ 2 - 14
src/Database/Type/FloatType.php

@@ -15,6 +15,7 @@
 namespace Cake\Database\Type;
 
 use Cake\Database\Driver;
+use Cake\Database\Type;
 use Cake\Database\TypeInterface;
 use PDO;
 use RuntimeException;
@@ -24,7 +25,7 @@ use RuntimeException;
  *
  * Use to convert float/decimal data between PHP and the database types.
  */
-class FloatType implements TypeInterface
+class FloatType extends Type implements TypeInterface
 {
 
     /**
@@ -45,19 +46,6 @@ class FloatType implements TypeInterface
     }
 
     /**
-     * Returns the base type name that this class is inheriting.
-     * This is useful when extending base type for adding extra functionality
-     * but still want the rest of the framework to use the same assumptions it would
-     * do about the base type it inherits from.
-     *
-     * @return string
-     */
-    public function getBaseType()
-    {
-        return $this->_name;
-    }
-
-    /**
      * The class to use for representing number objects
      *
      * @var string

+ 2 - 45
src/Database/Type/IntegerType.php

@@ -15,6 +15,7 @@
 namespace Cake\Database\Type;
 
 use Cake\Database\Driver;
+use Cake\Database\Type;
 use Cake\Database\TypeInterface;
 use InvalidArgumentException;
 use PDO;
@@ -24,54 +25,10 @@ use PDO;
  *
  * Use to convert integer data between PHP and the database types.
  */
-class IntegerType implements TypeInterface
+class IntegerType extends Type implements TypeInterface
 {
 
     /**
-     * Identifier name for this type
-     *
-     * @var string|null
-     */
-    protected $_name = null;
-
-    /**
-     * Constructor
-     *
-     * @param string|null $name The name identifying this type
-     */
-    public function __construct($name = null)
-    {
-        $this->_name = $name;
-    }
-
-    /**
-     * Returns the base type name that this class is inheriting.
-     * This is useful when extending base type for adding extra functionality
-     * but still want the rest of the framework to use the same assumptions it would
-     * do about the base type it inherits from.
-     *
-     * @return string
-     */
-    public function getBaseType()
-    {
-        return $this->_name;
-    }
-
-    /**
-     * Generate a new primary key value for a given type.
-     *
-     * This method can be used by types to create new primary key values
-     * when entities are inserted.
-     *
-     * @return mixed A new primary key value.
-     * @see \Cake\Database\Type\UuidType
-     */
-    public function newId()
-    {
-        return null;
-    }
-
-    /**
      * Convert integer data into the database format.
      *
      * @param mixed $value The value to convert.

+ 10 - 0
src/Database/TypeInterface.php

@@ -58,4 +58,14 @@ interface TypeInterface
      * @return mixed Converted value.
      */
     public function marshal($value);
+
+    /**
+     * Returns the base type name that this class is inheriting.
+     * This is useful when extending base type for adding extra functionality
+     * but still want the rest of the framework to use the same assumptions it would
+     * do about the base type it inherits from.
+     *
+     * @return string
+     */
+    public function getBaseType();
 }