コード例 #1
0
 /**
  * Processes the view for a specific template
  * @parma \ride\web\mvc\view\TemplateView $view
  * @return null
  */
 public function processView(TemplateView $view)
 {
     $template = $view->getTemplate();
     $result = $template->get('result');
     if (!$result) {
         return;
     }
     $model = $this->orm->getTaxonomyTermModel();
     $minWeight = 999999;
     $maxWeight = -1;
     foreach ($result as $index => $content) {
         if (!$content->data instanceof TaxonomyTerm) {
             unset($result[$index]);
             continue;
         }
         $content->data->weight = $model->calculateCloudWeight($content->data);
         $minWeight = min($minWeight, $content->data->weight);
         $maxWeight = max($maxWeight, $content->data->weight);
     }
     foreach ($result as $content) {
         $content->data->weightClass = $this->calculateWeightClass($content->data->weight, $minWeight, $maxWeight);
     }
     $template->set('result', $result);
 }