Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class PrimitiveEnumerationByValue extends PrimitiveEnumeration
00016 {
00017 public function import($scope)
00018 {
00019 if (!$this->className)
00020 throw new WrongStateException(
00021 "no class defined for PrimitiveEnumeration '{$this->name}'"
00022 );
00023
00024 if (isset($scope[$this->name])) {
00025 $scopedValue = urldecode($scope[$this->name]);
00026
00027 $anyId =
00028 ClassUtils::callStaticMethod($this->className.'::getAnyId');
00029
00030 $object = new $this->className($anyId);
00031
00032 $names = $object->getNameList();
00033
00034 foreach ($names as $key => $value) {
00035 if ($value == $scopedValue) {
00036 try {
00037 $this->value = new $this->className($key);
00038 } catch (MissingElementException $e) {
00039 $this->value = null;
00040 return false;
00041 }
00042
00043 return true;
00044 }
00045 }
00046
00047 return false;
00048 }
00049
00050 return null;
00051 }
00052 }
00053 ?>