To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Show
Ignore:
Timestamp:
04/29/10 17:02:27 (2 years ago)
Author:
dordille
Message:

Added aTools::cacheVirtualPages to avoid additional queries when using virtual pages.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/trunk/lib/toolkit/aTools.php

    r884 r1098  
    107107  } 
    108108 
     109  /** 
     110   * We've fetched a page on our own using aPageTable::queryWithSlots and we want 
     111   * to make Apostrophe aware of it so that areas on the current page that live on 
     112   * that virtual page don't generate a superfluous second query 
     113   * 
     114   * @param array, Doctrine_Collection, aPage $pages 
     115   */ 
     116  static public function cacheVirtualPages($pages) 
     117  { 
     118    if(get_class($pages) == 'Doctrine_Collection' || is_array($pages)) 
     119    { 
     120      foreach($pages as $page) 
     121      { 
     122        self::$globalCache[$page['slug']] = $page; 
     123      } 
     124    } 
     125    else 
     126    { 
     127      self::$globalCache[$pages['slug']] = $pages; 
     128    } 
     129  } 
     130 
    109131  static public function globalSetup($options) 
    110132  {