Revision: 67
http://sourceforge.net/p/beeframework/code/67
Author: m_plomer
Date: 2013-08-24 18:24:57 +0000 (Sat, 24 Aug 2013)
Log Message:
-----------
- EnumBase / 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 17:25:17 UTC (rev 66)
+++ trunk/framework/Bee/Persistence/Doctrine2/Types/EnumType.php 2013-08-24 18:24:57 UTC (rev 67)
@@ -17,11 +17,6 @@
private $values;
/**
- * @var string
- */
- private $name;
-
- /**
* @var \ReflectionClass
*/
private $reflClass;
@@ -29,22 +24,22 @@
/**
* @return string
*/
- protected abstract function getEnumClassName();
+ protected static function getEnumClassName() {
+ return null;
+ }
public function __construct() {
- $this->reflClass = new \ReflectionClass($this->getEnumClassName());
+ $this->reflClass = new \ReflectionClass(static::getEnumClassName());
if (!$this->reflClass->isSubclassOf(self::ENUM_BASE_TYPE)) {
throw new \UnexpectedValueException('"' . $this->reflClass . '" is not a subclass of "' . self::ENUM_BASE_TYPE . '"');
}
-
- $this->name = 'enum_' . str_replace('\\', '', $this->getEnumClassName());
}
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) {
$values = array_map(function ($val) {
return "'" . $val . "'";
}, $this->reflClass->getMethod('getValues')->invoke(null));
- return "ENUM(" . implode(", ", $values) . ") COMMENT '(DC2Type:" . $this->name . ")'";
+ return "ENUM(" . implode(", ", $values) . ") COMMENT '(DC2Type:" . $this->getName() . ")'";
}
public function convertToPHPValue($value, AbstractPlatform $platform) {
@@ -62,6 +57,10 @@
}
public function getName() {
- return $this->name;
+ return self::getEnumName();
}
+
+ public static function getEnumName() {
+ return 'enum_' . str_replace('\\', '', static::getEnumClassName());
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|