/**
  * 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);
 }
 /**
  * Renders the output for this view
  * @param boolean $willReturnValue True to return the rendered view, false
  * to send it straight to the client
  * @return null|string Null when provided $willReturnValue is set to true, the
  * rendered output otherwise
  */
 public function render($willReturnValue = true)
 {
     if (!$this->templateFacade) {
         throw new MvcException("Could not render template view: template facade not set, invoke setTemplateFacade() first");
     }
     $app = $this->template->get('app');
     // single content view
     if ($this->contentView) {
         $this->block = $this->contentViewBlock;
         $this->section = $this->contentViewSection;
         $this->region = $this->contentViewRegion;
         return $this->renderWidget($this->contentViewId, $this->contentView, $app, $willReturnValue);
     }
     // render the widget templates in the regions
     $regions = $this->template->get('widgets');
     foreach ($regions as $this->region => $sections) {
         foreach ($sections as $this->section => $blocks) {
             foreach ($blocks as $this->block => $widgets) {
                 foreach ($widgets as $widgetId => $widgetView) {
                     if (!$widgetView) {
                         continue;
                     }
                     // render the widget
                     $renderedWidget = $this->renderWidget($widgetId, $widgetView, $app);
                     if ($this->cache && isset($this->cachedViews[$this->region][$this->section][$this->block][$widgetId])) {
                         // cache the rendered view
                         $widgetCacheView = new WidgetCacheView($renderedWidget);
                         if ($widgetView instanceof HtmlView) {
                             $widgetCacheView->mergeResources($widgetView);
                         }
                         $this->cachedViews[$this->region][$this->section][$this->block][$widgetId]->setView($widgetCacheView);
                     }
                     if (trim($renderedWidget) == '') {
                         // omit empty widgets
                         unset($regions[$this->region][$this->section][$this->block][$widgetId]);
                     } else {
                         $regions[$this->region][$this->section][$this->block][$widgetId] = $renderedWidget;
                     }
                 }
                 // omit empty blocks
                 if (!$regions[$this->region][$this->section][$this->block]) {
                     unset($regions[$this->region][$this->section][$this->block]);
                 }
             }
             // omit empty sections
             if (!$regions[$this->region][$this->section]) {
                 unset($regions[$this->region][$this->section]);
             }
         }
         // omit empty regions
         if (!$regions[$this->region]) {
             unset($regions[$this->region]);
         }
     }
     if ($this->cache) {
         $this->cacheItem->setValue($this->cachedViews);
         $this->cache->set($this->cacheItem);
     }
     $this->template->set('widgets', $regions);
     return parent::render($willReturnValue);
 }