Development

Changeset 14108

You must first sign up to be able to contribute.

Changeset 14108

Show
Ignore:
Timestamp:
12/17/08 01:23:27 (1 year ago)
Author:
Jonathan.Wage
Message:

[1.2] sfDoctrinePlugin: fixes missing peer_method equiv. (closes #5324)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/configuration.php

    r13291 r14108  
    6060<?php include dirname(__FILE__).'/sortingConfiguration.php' ?> 
    6161 
     62  public function getTableMethod() 
     63  { 
     64    return '<?php echo isset($this->config['list']['table_method']) ? $this->config['list']['table_method'] : null ?>'; 
     65<?php unset($this->config['list']['table_method']) ?> 
     66  } 
     67 
     68  public function getTableCountMethod() 
     69  { 
     70    return '<?php echo isset($this->config['list']['table_count_method']) ? $this->config['list']['table_count_method'] : null ?>'; 
     71<?php unset($this->config['list']['table_count_method']) ?> 
     72  } 
     73 
    6274  public function getConnection() 
    6375  { 
  • branches/1.2/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/parts/paginationAction.php

    r12669 r14108  
    44    $pager->setQuery($this->buildQuery()); 
    55    $pager->setPage($this->getPage()); 
     6    $pager->setTableMethod($this->configuration->getTableMethod()); 
     7    $pager->setTableCountMethod($this->configuration->getTableCountMethod()); 
    68    $pager->init(); 
    79 
  • branches/1.2/lib/plugins/sfDoctrinePlugin/lib/pager/sfDoctrinePager.class.php

    r13394 r14108  
    1919class sfDoctrinePager extends sfPager implements Serializable 
    2020{ 
    21   protected $query; 
    22  
    23   /** 
    24    * __construct 
    25    * 
    26    * @return void 
    27    */ 
    28   public function __construct($class, $defaultMaxPerPage = 10) 
    29   { 
    30     parent::__construct($class, $defaultMaxPerPage); 
    31  
    32     $this->setQuery(Doctrine_Query::create()->from($class)); 
     21  protected 
     22    $query                 = null, 
     23    $tableMethodName       = null, 
     24    $tableCountMethodName  = null; 
     25 
     26  /** 
     27   * Get the name of the table method used to retrieve the query object for the pager 
     28   * 
     29   * @return string $tableMethodName 
     30   */ 
     31  public function getTableMethod() 
     32  { 
     33    return $this->tableMethodName; 
     34  } 
     35 
     36  /** 
     37   * Set the name of the table method used to retrieve the query object for the pager 
     38   * 
     39   * @param string $tableMethodName  
     40   * @return void 
     41   */ 
     42  public function setTableMethod($tableMethodName) 
     43  { 
     44    $this->tableMethodName = $tableMethodName; 
     45  } 
     46 
     47  /** 
     48   * Get the name of the table method used to retrieve the query object for the pager count 
     49   * 
     50   * @return string $tableCountMethodName 
     51   */ 
     52  public function getTableCountMethod() 
     53  { 
     54    return $this->tableCountMethodName; 
     55  } 
     56 
     57  /** 
     58   * Set the name of the table method used to retrieve the query object for the pager count 
     59   * 
     60   * @param string $tableCountMethodName  
     61   * @return void 
     62   */ 
     63  public function setTableCountMethod($tableCountMethodName) 
     64  { 
     65    $this->tableCountMethodName = $tableCountMethodName; 
    3366  } 
    3467 
     
    6194  } 
    6295 
     96  public function getCountQuery() 
     97  { 
     98    if (!$this->tableCountMethodName) 
     99    { 
     100      $q = clone $this->getQuery() 
     101        ->offset(0) 
     102        ->limit(0); 
     103 
     104      return $q; 
     105    } else { 
     106      $method = $this->tableCountMethodName; 
     107      return Doctrine::getTable($this->getClass())->$method(); 
     108    } 
     109  } 
     110 
    63111  /** 
    64112   * Initialize the pager instance and prepare it to be used for rendering 
     
    68116  public function init() 
    69117  { 
    70     $count = $this->getQuery()->offset(0)->limit(0)->count(); 
     118    $countQuery = $this->getCountQuery(); 
     119    $count = $countQuery->count(); 
    71120 
    72121    $this->setNbResults($count); 
     
    97146  public function getQuery() 
    98147  { 
    99     return $this->query; 
     148    if (!$this->tableMethodName) 
     149    { 
     150      if (!$this->query) 
     151      { 
     152        $this->query = Doctrine_Query::create()->from($this->getClass()); 
     153      } 
     154 
     155      return $this->query; 
     156    } else { 
     157      $method = $this->tableMethodName; 
     158      return Doctrine::getTable($this->getClass())->$method(); 
     159    } 
    100160  } 
    101161 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.