Oops, added missing parseValue for EnumType

This commit is contained in:
vladar 2015-09-06 15:49:23 +06:00
parent 83e33659cb
commit c312f73df3

View File

@ -53,12 +53,30 @@ class EnumType extends Type implements InputType, OutputType
return $this->_values; return $this->_values;
} }
/**
* @param $value
* @return null
*/
public function serialize($value) public function serialize($value)
{ {
$enumValue = $this->_getValueLookup()->offsetGet($value); $lookup = $this->_getValueLookup();
return $enumValue ? $enumValue->name : null; return isset($lookup[$value]) ? $lookup[$value]->name : null;
} }
/**
* @param $value
* @return null
*/
public function parseValue($value)
{
$lookup = $this->_getNameLookup();
return isset($lookup[$value]) ? $lookup[$value]->value : null;
}
/**
* @param $value
* @return null
*/
public function parseLiteral($value) public function parseLiteral($value)
{ {
if ($value instanceof EnumValue) { if ($value instanceof EnumValue) {