# PrimitiveAlias.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /****************************************************************************
    00003  *   Copyright (C) 2008-2010 by Konstantin V. Arkhipov                      *
    00004  *                                                                          *
    00005  *   This program is free software; you can redistribute it and/or modify   *
    00006  *   it under the terms of the GNU Lesser General Public License as         *
    00007  *   published by the Free Software Foundation; either version 3 of the     *
    00008  *   License, or (at your option) any later version.                        *
    00009  *                                                                          *
    00010  ****************************************************************************/
    00011
    00015     final class PrimitiveAlias extends BasePrimitive
    00016     {
    00017         private $primitive = null;
    00018
    00019         public function __construct($name, BasePrimitive $prm)
    00020         {
    00021             $this->name = $name;
    00022             $this->primitive = $prm;
    00023         }
    00024
    00025         public function getInner()
    00026         {
    00027             return $this->primitive;
    00028         }
    00029
    00030         public function getName()
    00031         {
    00032             return $this->name;
    00033         }
    00034
    00035         public function getDefault()
    00036         {
    00037             return $this->primitive->getDefault();
    00038         }
    00039
    00043         public function setDefault($default)
    00044         {
    00045             $this->primitive->setDefault($default);
    00046
    00047             return $this;
    00048         }
    00049
    00050         public function getValue()
    00051         {
    00052             return $this->primitive->getValue();
    00053         }
    00054
    00055         public function getRawValue()
    00056         {
    00057             return $this->primitive->getRawValue();
    00058         }
    00059
    00063         public function getActualValue()
    00064         {
    00065             if (null !== $this->primitive->getValue())
    00066                 return $this->primitive->getValue();
    00067             elseif ($this->primitive->isImported())
    00068                 return $this->primitive->getRawValue();
    00069
    00070             return $this->primitive->getDefault();
    00071         }
    00072
    00073         public function getSafeValue()
    00074         {
    00075             if ($this->primitive->isImported())
    00076                 return $this->primitive->getValue();
    00077
    00078             return $this->primitive->getDefault();
    00079         }
    00080
    00081         public function getFormValue()
    00082         {
    00083             if (!$this->primitive->isImported()) {
    00084                 if ($this->primitive->getValue() === null)
    00085                     return null;
    00086
    00087                 return $this->primitive->exportValue();
    00088             }
    00089
    00090             return $this->primitive->getRawValue();
    00091         }
    00092
    00096         public function setValue($value)
    00097         {
    00098             $this->primitive->setValue($value);
    00099
    00100             return $this;
    00101         }
    00102
    00106         public function dropValue()
    00107         {
    00108             $this->primitive->dropValue();
    00109
    00110             return $this;
    00111         }
    00112
    00116         public function setRawValue($raw)
    00117         {
    00118             $this->primitive->setRawValue($raw);
    00119
    00120             return $this;
    00121         }
    00122
    00123         public function isImported()
    00124         {
    00125             return $this->primitive->isImported();
    00126         }
    00127
    00131         public function clean()
    00132         {
    00133             $this->primitive->clean();
    00134
    00135             return $this;
    00136         }
    00137
    00138         public function importValue($value)
    00139         {
    00140             return $this->primitive->importValue($value);
    00141         }
    00142
    00143         public function exportValue()
    00144         {
    00145             return $this->primitive->exportValue();
    00146         }
    00147
    00148         public function getCustomError()
    00149         {
    00150             return $this->primitive->getCustomError();
    00151         }
    00152
    00153         public function import($scope)
    00154         {
    00155             if (array_key_exists($this->name, $scope))
    00156                 return $this->primitive->importValue($scope[$this->name]);
    00157
    00158             return null;
    00159         }
    00160     }
    00161 ?>