/** * If culture is null you get the current user's culture, * or sf_default_culture if none is set or we're running in a task context * @param mixed $slug * @param mixed $culture * @return mixed */ public static function retrieveBySlugWithSlots($slug, $culture = null) { if (is_null($culture)) { $culture = aTools::getUserCulture(); } $query = aPageTable::queryWithSlots(false, $culture); $pageInfo = null; if (sfConfig::get('app_a_fasthydrate', false)) { $pageInfo = $query->andWhere('p.slug = ?', $slug)->fetchOne(array(), Doctrine::HYDRATE_ARRAY); if ($pageInfo) { $page = new aPage(); $page->hydrate($pageInfo); } else { $page = null; } } else { $page = $query->andWhere('p.slug = ?', $slug)->fetchOne(); } if ($page) { // In case Doctrine is clever and returns the same page object $page->clearSlotCache(); $page->setCulture($culture); // Cheap hydration of the slots happens here $page->populateSlotCache($pageInfo['Areas']); } return $page; }
/** * * Caches a page for the current request so that other invocations of a_slot, a_area, * etc. can efficiently access it without another query. Also hydrates the page if the * data passed in is from an array-hydrated query (part of app_a_fasthydrate). Returns the * page object, particularly useful if you need to map it back to an object it is * associated with as part of fast hydration */ public static function cacheVirtualPage($pageInfo) { if (!is_object($pageInfo)) { // Fast hydration $page = new aPage(); $page->hydrate($pageInfo); // Cheap hydration of the slots happens here $page->populateSlotCache($pageInfo['Areas']); } else { $page = $pageInfo; } aTools::$globalCache[$page['slug']] = $page; return $page; }