Piwik\View::render PHP Method

render() public method

See {@link setContentType()}.
public render ( ) : string
return string Generated template.
    public function render()
    {
        try {
            $this->currentModule = Piwik::getModule();
            $this->currentAction = Piwik::getAction();
            $this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
            $this->token_auth = Piwik::getCurrentUserTokenAuth();
            $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
            $this->userIsAnonymous = Piwik::isUserIsAnonymous();
            $this->userIsSuperUser = Piwik::hasUserSuperUserAccess();
            $this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
            $this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
            $this->isWidget = Common::getRequestVar('widget', 0, 'int');
            $this->isMultiServerEnvironment = SettingsPiwik::isMultiServerEnvironment();
            $piwikAds = StaticContainer::get('Piwik\\ProfessionalServices\\Advertising');
            $this->areAdsForProfessionalServicesEnabled = $piwikAds->areAdsForProfessionalServicesEnabled();
            if (Development::isEnabled()) {
                $cacheBuster = rand(0, 10000);
            } else {
                $cacheBuster = UIAssetCacheBuster::getInstance()->piwikVersionBasedCacheBuster();
            }
            $this->cacheBuster = $cacheBuster;
            $this->loginModule = Piwik::getLoginPluginName();
            $user = APIUsersManager::getInstance()->getUser($this->userLogin);
            $this->userAlias = $user['alias'];
        } catch (Exception $e) {
            Log::debug($e);
            // can fail, for example at installation (no plugin loaded yet)
        }
        ProxyHttp::overrideCacheControlHeaders('no-store');
        Common::sendHeader('Content-Type: ' . $this->contentType);
        // always sending this header, sometimes empty, to ensure that Dashboard embed loads
        // - when calling sendHeader() multiple times, the last one prevails
        Common::sendHeader('X-Frame-Options: ' . (string) $this->xFrameOptions);
        return $this->renderTwigTemplate();
    }

Usage Example

Example #1
0
 public function index()
 {
     $view = new View('@VisitTime/index');
     $view->dataTableVisitInformationPerLocalTime = $this->renderReport(new GetVisitInformationPerLocalTime());
     $view->dataTableVisitInformationPerServerTime = $this->renderReport(new GetVisitInformationPerServerTime());
     return $view->render();
 }
All Usage Examples Of Piwik\View::render