Revision: 63
http://sourceforge.net/p/beeframework/code/63
Author: m_plomer
Date: 2013-08-24 13:53:48 +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:41:15 UTC (rev 62)
+++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 13:53:48 UTC (rev 63)
@@ -9,21 +9,33 @@
*/
abstract class EnumType extends Type
{
+ /**
+ * @var array
+ */
private $values;
+ /**
+ * @var string
+ */
private $name;
- protected abstract function getEnumClassName();
+ public function __construct() {
+ $reflClass = new \ReflectionClass($this);
+ $this->values = array_diff_key($reflClass->getConstants(), array('ENUM_NAME'));
+ $this->name = $reflClass->getConstant('ENUM_NAME');
- public function __construct() {
- $reflClass = new \ReflectionClass($this->getEnumClassName());
- $this->values = $reflClass->getConstants();
- $this->name = 'enum_' . str_replace('\\', '_', $this->getEnumClassName());
+ echo '<hr/>EnumType ' . get_class($this) . '<br/>';
+ var_dump($this);
+ echo '<hr/>';
}
+ protected function getValues() {
+ return $this->values;
+ }
+
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
- $values = array_map(function($val) { return "'".$val."'"; }, $this->values);
+ $values = array_map(function($val) { return "'".$val."'"; }, $this->getValues());
return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'";
}
@@ -35,7 +47,7 @@
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
- if (!in_array($value, $this->values)) {
+ if (!in_array($value, $this->getValues())) {
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.
|