Advertisement
spider75

EnumType.php

Jun 16th, 2011
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. namespace Acme\TestBundle\Types;
  3.  
  4. use Doctrine\DBAL\Types\Type;
  5. use Doctrine\DBAL\Platforms\AbstractPlatform;
  6.  
  7. /**
  8.  * My custom datatype.
  9.  */
  10. class EnumType extends Type
  11. {
  12.     const ENUM = 'enum'; // modify to match your type name
  13.  
  14.     public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
  15.     {
  16.         return 'enum';
  17.     }
  18.  
  19.     public function convertToPHPValue($value, AbstractPlatform $platform)
  20.     {
  21.         return new Enum($value);
  22.     }
  23.  
  24.     public function convertToDatabaseValue($value, AbstractPlatform $platform)
  25.     {
  26.         return $value->toString();
  27.     }
  28.  
  29.     public function getName()
  30.     {
  31.         return self::ENUM;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement