Show
Ignore:
Timestamp:
09/16/08 01:32:33 (4 months ago)
Author:
nowelium
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/misc/Hermit/src/Hermit/proxy/HermitInterfaceProxy.php

    r19017 r19344  
    44 * @author nowelium 
    55 */ 
    6 class HermitInterfaceProxy implements HermitProxy { 
    7     protected $pdo; 
     6class HermitInterfaceProxy implements HermitFutureProxy { 
    87    protected $reflector; 
    9     protected function __construct(ReflectionClass $reflector, $pdo){ 
     8    protected $commandFactory; 
     9    protected function __construct(ReflectionClass $reflector){ 
    1010        $this->reflector = $reflector; 
    11         $this->pdo = $pdo; 
     11        $this->commandFactory = new HermitSqlCommandFactory($reflector); 
    1212    } 
    13     public static function delegate(PDO $pdo, ReflectionClass $reflector, $instance = null){ 
    14         return new self($reflector, $pdo); 
     13    public static function delegate(ReflectionClass $reflector, $instance = null){ 
     14        return new self($reflector); 
    1515    } 
    16     public function __call($name, $params = array()){ 
    17         $annote = HermitAnnote::create($this->reflector); 
    18         if(!$annote->hasMethod($name)){ 
     16    public function request($name, array $params){ 
     17        if(!$this->commandFactory->hasCommand($name)){ 
    1918            throw new BadMethodCallException($this->reflector->getName() . '::' . $name); 
    2019        } 
    21  
    22         $method = $annote->getMethod($name); 
    23         switch(true){ 
    24         case $annote->hasSql($name): 
    25             return $this->execute($method, $params, $annote->getSql($name)); 
    26         case $annote->hasQuery($name): 
    27             $sql = 'SELECT * FROM ' . $annote->getTable() . ' WHERE ' . $annote->getQuery($name); 
    28             return $this->execute($method, $params, $sql); 
    29         case $annote->hasFile($name): 
    30             return $this->execute($method, $params, $annote->getFile($name)); 
    31         case $annote->hasPath($name): 
    32             return $this->execute($method, $params, $annote->getPath($name)); 
    33         case $annote->hasDelegate($name); 
    34             break; 
    35         } 
    36         throw new BadMethodCallException($this->reflector->getName() . '::' . $name); 
    37     } 
    38     protected function execute(ReflectionMethod $method, $params, $sql){ 
    39         $stmt = HermitStatementBuilder::prepare($this->pdo, $method, $sql); 
    40         $stmt->execute($params); 
    41         return HermitResultSet::create($stmt, $method); 
     20        $command = $this->commandFactory->getCommand($name); 
     21        return $command->execute($pdo, $params); 
    4222    } 
    4323}