/** * load * static method to pre-load the specified settings into memory. Use this * early in execution to avoid multiple SQL calls for individual settings. * Takes either a string or an array of strings as an argument. * * @param mixed $settings * @static * @access public * @return void */ static function init($settings, $navigation, $rebuild = false) { // Implements Caching for navigation tree $cachePath = sfConfig::get('sf_cache_dir') . '/navigation_tree.cache'; if (!file_exists($cachePath)) { // Populate the Navigation Tree if (isset($settings['database']['driven']) && $settings['database']['driven']) { //Populate Tree from Database if ($rebuild || !Doctrine::getTable('csNavigationItem')->isPopulated()) { //Build Database from Existing navigation.yml file $tree = self::initDatabaseFromYaml($navigation, $rebuild); } else { //Pull from database, create navigation structure $tree = self::getNavigationTreeFromDatabase(); } } else { //Populate tree from navigation.yml $tree = self::getNavigationTreeFromYaml($navigation); } $menuTable = Doctrine::getTable('csNavigationMenu'); $menuTable->storeTree($tree); // Run the configure() method for dynamically adding branches Doctrine::getTable('csNavigationMenu')->configure(); $tree = $menuTable->restoreTree(); // Cache Tree $serialized = serialize($tree->toArray()); file_put_contents($cachePath, $serialized); } else { Doctrine::getTable('csNavigationMenu')->storeTree(self::getTree()); } self::$_settings = $settings; }
/** * execute * * @param mixed $filterChain * @access public * @return void */ public function execute($filterChain) { if ($this->isFirstCall()) { if (file_exists(sfConfig::get('sf_config_dir') . '/navigation.yml')) { $path = sfConfig::get('sf_config_dir') . '/navigation.yml'; } else { $path = sfConfig::get('sf_app_config_dir') . '/navigation.yml'; } include sfContext::getInstance()->getConfigCache()->checkConfig($path); csNavigationHelper::init($settings, $navigation); } $filterChain->execute(); }
protected function execute($arguments = array(), $options = array()) { $app = $arguments['application']; $env = $options['env']; $this->checkAppExists($app); $this->bootstrapSymfony($app, $env, true); $context = sfContext::getInstance(); // Remove existing cache files $this->runSymfonyCacheClear(); $this->logSection('navigation', 'loading navigation.yml'); /* TODO What happens when the user has two or more applications with separate navigation.yml files? We may want to restructure (migrate) the tree rather than drop it and rebuild it! */ if (file_exists(sfConfig::get('sf_config_dir') . '/navigation.yml')) { $path = sfConfig::get('sf_config_dir') . '/navigation.yml'; } else { $path = sfConfig::get('sf_app_config_dir') . '/navigation.yml'; } include sfContext::getInstance()->getConfiguration()->getConfigCache()->checkConfig($path); csNavigationHelper::init($settings, $navigation, true); $this->logSection('navigation', "Completed."); }