protected function execute($arguments = array(), $options = array()) { // We need a proper environment. This also gives us superadmin privileges aTaskTools::signinAsTaskUser($this->createConfiguration($options['application'], $options['env']), $options['connection']); aTaskTools::setCliHost(); // Get all of the current pages with their slots. For efficiency this normally does not return slots // that are not the current version if ($options['allversions']) { // All versions case is a simpler query since we want to look at every slot $slots = Doctrine::getTable('aSlot')->findAll(); foreach ($slots as $slot) { $slot->refreshSlot(); } } else { // All cultures $pages = aPageTable::queryWithSlots(false, 'all')->execute(); foreach ($pages as $page) { foreach ($page->Areas as $area) { foreach ($area->AreaVersions as $areaVersion) { foreach ($areaVersion->AreaVersionSlots as $areaVersionSlot) { $areaVersionSlot->Slot->refreshSlot(); } } } } } }
/** * Given an array of blogItems this function will populate its virtual page * areas with the current slot versions. * @param aBlogItem $blogItems */ public static function populatePages($blogItems) { $pageIds = array(); foreach ($blogItems as $aBlogItem) { $pageIds[] = $aBlogItem['page_id']; } if (count($pageIds)) { $q = aPageTable::queryWithSlots(); $q->whereIn('id', $pageIds); $pages = $q->execute(); aTools::cacheVirtualPages($pages); } }
/** * 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 $id * @param mixed $version * @param mixed $culture * @return mixed */ public static function retrieveByIdWithSlotsForVersion($id, $version, $culture = null) { if (is_null($culture)) { $culture = aTools::getUserCulture(); } $page = aPageTable::queryWithSlots($version, $culture)->andWhere('p.id = ?', array($id))->fetchOne(); // In case Doctrine is clever and returns the same page object if ($page) { $page->clearSlotCache(); // Thanks to Quentin Dugauthier for spotting that there were // still instances of this not being inside the if $page->setCulture($culture); } return $page; }
public function queryWithPages($query = null) { if (is_null($query)) { $query = $this->createQuery(); } $query->leftJoin($query->getRootAlias() . '.Page p'); $query = aPageTable::queryWithSlots(false, null, $query); return $query; }