PrimitiveArray.class.php

Go to the documentation of this file.
00001 <?php
00002 /****************************************************************************
00003  *   Copyright (C) 2004-2007 by Konstantin V. Arkhipov, Anton E. Lebedevich *
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 /* $Id: PrimitiveArray.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class PrimitiveArray extends FiltrablePrimitive
00017     {
00025         private $fetchMode = null;
00026         
00030         public function setFetchMode($ternary)
00031         {
00032             Assert::isTernaryBase($ternary);
00033             
00034             $this->fetchMode = $ternary;
00035             
00036             return $this;
00037         }
00038         
00039         public function import($scope)
00040         {
00041             if (!BasePrimitive::import($scope))
00042                 return null;
00043             
00044             $this->value = $scope[$this->name];
00045             
00046             $this->selfFilter();
00047             
00048             if (
00049                 is_array($this->value)
00050                 && !($this->min && count($this->value) < $this->min)
00051                 && !($this->min && count($this->value) > $this->max)
00052             ) {
00053                 return true;
00054             } else {
00055                 $this->value = null;
00056             }
00057             
00058             return false;
00059         }
00060         
00061         public function importValue($value)
00062         {
00063             if ($value instanceof UnifiedContainer) {
00064                 if (
00065                     ($this->fetchMode !== null)
00066                     && ($value->getParentObject()->getId())
00067                 ) {
00068                     if ($value->isLazy() === $this->fetchMode) {
00069                         $value = $value->getList();
00070                     } else {
00071                         $className = get_class($value);
00072                         
00073                         $containter = new $className(
00074                             $value->getParentObject(),
00075                             $this->fetchMode
00076                         );
00077                         
00078                         $value = $containter->getList();
00079                     }
00080                 } elseif (!$value->isFetched())
00081                     return null;
00082             }
00083             
00084             if (is_array($value))
00085                 return $this->import(array($this->getName() => $value));
00086             
00087             return false;
00088         }
00089     }
00090 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4