Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class PrimitiveMultiList extends PrimitiveList
00016 {
00017 private $selected = array();
00018
00019 public function getChoiceValue()
00020 {
00021 return $this->selected;
00022 }
00023
00024 public function getActualChoiceValue()
00025 {
00026 if ($this->value !== null)
00027 return $this->selected;
00028 elseif ($this->default) {
00029 $out = array();
00030
00031 foreach ($this->default as $index)
00032 $out[] = $this->list[$index];
00033
00034 return $out;
00035 }
00036
00037 return array();
00038 }
00039
00043 public function setDefault($default)
00044 {
00045 Assert::isArray($default);
00046
00047 foreach ($default as $index)
00048 Assert::isTrue(array_key_exists($index, $this->list));
00049
00050 return parent::setDefault($default);
00051 }
00052
00053 public function import($scope)
00054 {
00055 if (!BasePrimitive::import($scope))
00056 return null;
00057
00058 if (!$this->list)
00059 throw new WrongStateException(
00060 'list to check is not set; '
00061 .'use PrimitiveArray in case it is intentional'
00062 );
00063
00064 if (is_array($scope[$this->name])) {
00065 $values = array();
00066
00067 foreach ($scope[$this->name] as $value) {
00068 if (isset($this->list[$value])) {
00069 $values[] = $value;
00070 $this->selected[$value] = $this->list[$value];
00071 }
00072 }
00073
00074 if (count($values)) {
00075 $this->value = $values;
00076
00077 return true;
00078 }
00079 } elseif (!empty($scope[$this->name])) {
00080 $this->value = array($scope[$this->name]);
00081
00082 return true;
00083 }
00084
00085 return false;
00086 }
00087
00091 public function clean()
00092 {
00093 $this->selected = array();
00094
00095 return parent::clean();
00096 }
00097
00098 public function exportValue()
00099 {
00100 throw new UnimplementedFeatureException();
00101 }
00102 }
00103 ?>