Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class PrimitiveHstore extends BasePrimitive
00016 {
00017 protected $formMapping = array();
00018
00022 public function setFormMapping($array)
00023 {
00024 $this->formMapping = $array;
00025
00026 return $this;
00027 }
00028
00029 public function getFormMapping()
00030 {
00031 return $this->formMapping;
00032 }
00033
00034 public function getInnerErrors()
00035 {
00036 if ($this->value instanceof Form)
00037 return $this->value->getInnerErrors();
00038
00039 return array();
00040 }
00041
00045 public function getInnerForm()
00046 {
00047 return $this->value;
00048 }
00049
00050 public function getValue()
00051 {
00052 return $this->exportValue();
00053 }
00054
00059 public function importValue($value)
00060 {
00061 if ($value === null)
00062 return parent::importValue(null);
00063
00064 Assert::isTrue($value instanceof Hstore, 'importValue');
00065
00066 if (!$this->value instanceof Form)
00067 $this->value = $this->makeForm();
00068
00069 $this->value->import($value->getList());
00070 $this->imported = true;
00071
00072 return
00073 $this->value->getErrors()
00074 ? false
00075 : true;
00076 }
00077
00078 public function import($scope)
00079 {
00080 if (!isset($scope[$this->name]))
00081 return null;
00082
00083 $this->rawValue = $scope[$this->name];
00084
00085 if (!$this->value instanceof Form)
00086 $this->value = $this->makeForm();
00087
00088 $this->value->import($this->rawValue);
00089
00090 $this->imported = true;
00091
00092 if ($this->value->getErrors())
00093 return false;
00094
00095 return true;
00096 }
00097
00101 public function exportValue()
00102 {
00103 if (!$this->value instanceof Form)
00104 return null;
00105
00106 return Hstore::make($this->value->export());
00107 }
00108
00112 protected function makeForm()
00113 {
00114 $form = Form::create();
00115
00116 foreach ($this->getFormMapping() as $primitive)
00117 $form->add($primitive);
00118
00119 return $form;
00120 }
00121 }
00122 ?>