setController() public method

public setController ( $controllerName, $controllerAction )
Beispiel #1
0
 /**
  * Constructor. Initializes display and request properties to their default values.
  * Posts the {@hook ViewDataTable.configure} event which plugins can use to configure the
  * way reports are displayed.
  */
 public function __construct($controllerAction, $apiMethodToRequestDataTable, $overrideParams = array())
 {
     list($controllerName, $controllerAction) = explode('.', $controllerAction);
     $this->requestConfig = static::getDefaultRequestConfig();
     $this->config = static::getDefaultConfig();
     $this->config->subtable_controller_action = $controllerAction;
     $this->config->setController($controllerName, $controllerAction);
     $this->request = new ViewDataTableRequest($this->requestConfig);
     $this->requestConfig->idSubtable = Common::getRequestVar('idSubtable', false, 'int');
     $this->config->self_url = Request::getBaseReportUrl($controllerName, $controllerAction);
     $this->requestConfig->apiMethodToRequestDataTable = $apiMethodToRequestDataTable;
     $report = Report::factory($this->requestConfig->getApiModuleToRequest(), $this->requestConfig->getApiMethodToRequest());
     if (!empty($report)) {
         /** @var Report $report */
         $subtable = $report->getActionToLoadSubTables();
         if (!empty($subtable)) {
             $this->config->subtable_controller_action = $subtable;
         }
         $this->config->show_goals = $report->hasGoalMetrics();
         $relatedReports = $report->getRelatedReports();
         if (!empty($relatedReports)) {
             foreach ($relatedReports as $relatedReport) {
                 $widgetTitle = $relatedReport->getWidgetTitle();
                 if ($widgetTitle && Common::getRequestVar('widget', 0, 'int')) {
                     $relatedReportName = $widgetTitle;
                 } else {
                     $relatedReportName = $relatedReport->getName();
                 }
                 $this->config->addRelatedReport($relatedReport->getModule() . '.' . $relatedReport->getAction(), $relatedReportName);
             }
         }
         $metrics = $report->getMetrics();
         if (!empty($metrics)) {
             $this->config->addTranslations($metrics);
         }
         $processedMetrics = $report->getProcessedMetrics();
         if (!empty($processedMetrics)) {
             $this->config->addTranslations($processedMetrics);
         }
         $report->configureView($this);
     }
     /**
      * Triggered during {@link ViewDataTable} construction. Subscribers should customize
      * the view based on the report that is being displayed.
      *
      * Plugins that define their own reports must subscribe to this event in order to
      * specify how the Piwik UI should display the report.
      *
      * **Example**
      *
      *     // event handler
      *     public function configureViewDataTable(ViewDataTable $view)
      *     {
      *         switch ($view->requestConfig->apiMethodToRequestDataTable) {
      *             case 'VisitTime.getVisitInformationPerServerTime':
      *                 $view->config->enable_sort = true;
      *                 $view->requestConfig->filter_limit = 10;
      *                 break;
      *         }
      *     }
      *
      * @param ViewDataTable $view The instance to configure.
      */
     Piwik::postEvent('ViewDataTable.configure', array($this));
     $this->assignRelatedReportsTitle();
     $this->config->show_footer_icons = false == $this->requestConfig->idSubtable;
     // the exclude low population threshold value is sometimes obtained by requesting data.
     // to avoid issuing unecessary requests when display properties are determined by metadata,
     // we allow it to be a closure.
     if (isset($this->requestConfig->filter_excludelowpop_value) && $this->requestConfig->filter_excludelowpop_value instanceof \Closure) {
         $function = $this->requestConfig->filter_excludelowpop_value;
         $this->requestConfig->filter_excludelowpop_value = $function();
     }
     $this->overrideViewPropertiesWithParams($overrideParams);
     $this->overrideViewPropertiesWithQueryParams();
 }
 /**
  * Constructor. Initializes display and request properties to their default values.
  * Posts the {@hook ViewDataTable.configure} event which plugins can use to configure the
  * way reports are displayed.
  */
 public function __construct($controllerAction, $apiMethodToRequestDataTable)
 {
     list($controllerName, $controllerAction) = explode('.', $controllerAction);
     $this->requestConfig = static::getDefaultRequestConfig();
     $this->config = static::getDefaultConfig();
     $this->config->subtable_controller_action = $controllerAction;
     $this->config->setController($controllerName, $controllerAction);
     $this->request = new ViewDataTableRequest($this->requestConfig);
     $this->requestConfig->idSubtable = Common::getRequestVar('idSubtable', false, 'int');
     $this->config->self_url = Request::getBaseReportUrl($controllerName, $controllerAction);
     $this->requestConfig->apiMethodToRequestDataTable = $apiMethodToRequestDataTable;
     /**
      * Triggered during {@link ViewDataTable} construction. Subscribers should customize
      * the view based on the report that is being displayed.
      * 
      * Plugins that define their own reports must subscribe to this event in order to
      * specify how the Piwik UI should display the report.
      * 
      * **Example**
      *
      *     // event handler
      *     public function configureViewDataTable(ViewDataTable $view)
      *     {
      *         switch ($view->requestConfig->apiMethodToRequestDataTable) {
      *             case 'VisitTime.getVisitInformationPerServerTime':
      *                 $view->config->enable_sort = true;
      *                 $view->requestConfig->filter_limit = 10;
      *                 break;
      *         }
      *     }
      * 
      * @param ViewDataTable $view The instance to configure.
      */
     Piwik::postEvent('ViewDataTable.configure', array($this));
     $this->config->show_footer_icons = false == $this->requestConfig->idSubtable;
     // the exclude low population threshold value is sometimes obtained by requesting data.
     // to avoid issuing unecessary requests when display properties are determined by metadata,
     // we allow it to be a closure.
     if (isset($this->requestConfig->filter_excludelowpop_value) && $this->requestConfig->filter_excludelowpop_value instanceof \Closure) {
         $function = $this->requestConfig->filter_excludelowpop_value;
         $this->requestConfig->filter_excludelowpop_value = $function();
     }
     $this->overrideViewPropertiesWithQueryParams();
 }