Revision: 62
http://sourceforge.net/p/beeframework/code/62
Author: m_plomer
Date: 2013-08-24 13:41:15 +0000 (Sat, 24 Aug 2013)
Log Message:
-----------
- fixed Doctrine2 EnumType
Modified Paths:
--------------
trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php
Modified: trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php
===================================================================
--- trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:26:16 UTC (rev 61)
+++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:41:15 UTC (rev 62)
@@ -9,31 +9,21 @@
*/
abstract class EnumType extends Type
{
- /**
- * @var \ReflectionClass
- */
- private $reflClass;
-
private $values;
private $name;
+ protected abstract function getEnumClassName();
+
public function __construct() {
- $this->reflClass = new \ReflectionClass($this);
- $this->values = array_diff_key($this->reflClass->getConstants(), array('ENUM_NAME'));
-
- echo '<hr/>EnumType ' . get_class($this) . '<br/>';
- var_dump($this);
- echo '<hr/>';
+ $reflClass = new \ReflectionClass($this->getEnumClassName());
+ $this->values = $reflClass->getConstants();
+ $this->name = 'enum_' . str_replace('\\', '_', $this->getEnumClassName());
}
- protected function getValues() {
- return $this->values;
- }
-
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
- $values = array_map(function($val) { return "'".$val."'"; }, $this->getValues());
+ $values = array_map(function($val) { return "'".$val."'"; }, $this->values);
return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'";
}
@@ -45,7 +35,7 @@
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
- if (!in_array($value, $this->getValues())) {
+ if (!in_array($value, $this->values)) {
throw new \InvalidArgumentException("Invalid '".$this->name."' value.");
}
return $value;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|