# ClassProjection.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2007 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     class ClassProjection implements ObjectProjection
    00016     {
    00017         protected $className    = null;
    00018
    00022         public static function create($class)
    00023         {
    00024             return new self($class);
    00025         }
    00026
    00027         public function __construct($class)
    00028         {
    00029             Assert::isTrue(
    00030                 ClassUtils::isInstanceOf($class, 'Prototyped')
    00031             );
    00032
    00033             if (is_object($class))
    00034                 $this->className = get_class($class);
    00035             else
    00036                 $this->className = $class;
    00037         }
    00038
    00042         public function process(Criteria $criteria, JoinCapableQuery $query)
    00043         {
    00044             $dao = call_user_func(array($this->className, 'dao'));
    00045
    00046             foreach ($dao->getFields() as $field)
    00047                 $this->subProcess(
    00048                     $query,
    00049                     DBField::create($field, $dao->getTable())
    00050                 );
    00051
    00052             return $query;
    00053         }
    00054
    00055         /* void */ protected function subProcess(
    00056             JoinCapableQuery $query, DBField $field
    00057         )
    00058         {
    00059             $query->get($field);
    00060         }
    00061     }
    00062 ?>