/** * Populate the array of site links * @param array[] &$list The array which holds the array of link information: loc, frequency, priority * @param ESitemapModel[] $classesConfig Array of class configuration Models * @param string $default_scope The default scope to use if one is not defined in the class. Defaults to 'sitemap' * @return array[] */ public function populateSitemap( $list, $classes, $default_scope = 'sitemap' ) { // Loop through each of the classes, setting the defaults for all models // of that type and then setting the specific model attributes into the // listing for the class type foreach( $classes as $modelType ) { $esm = new ESitemapModel; $esm->attributes = $modelType; if (!$esm->validate()) { Yii::log('Impropertly configured sitemap class object: '.print_r($esm->errors, true), 'warning', 'ext.sitemap.ESitemapBeahvior'); continue; //throw new CException('Improperly configured sitemap class object: '.print_r($esm->errors, true)); } $models = $esm->models; foreach( $models as $model ) { $list[] = array( // replace model slugs with model attribute values 'loc'=> $esm->loc($model), 'frequency'=>$esm->frequency, 'priority'=>$esm->priority, ); } } return $list; }
/** * Ensure that we're able to look up the models with the specified scope */ public function testESitemapModelDataLookup() { $e = new ESitemapModel(); $e->attributes = array('baseModel' => 'Task'); $this->assertTrue($e->validate()); $data = $e->models; $this->assertNotNull($data); $model = $data[0]; $this->assertNotNull($model); $this->assertTrue(get_class($model) == 'Task'); }