Piwik\Plugins\CoreHome\DataTableRowAction\RowEvolution::__construct PHP Метод

__construct() публичный Метод

The constructor Initialize some local variables from the request
public __construct ( integer $idSite, Date $date, null | string $graphType = 'graphEvolution' )
$idSite integer
$date Piwik\Date ($this->date from controller)
$graphType null | string
    public function __construct($idSite, $date, $graphType = 'graphEvolution')
    {
        $this->apiMethod = Common::getRequestVar('apiMethod', '', 'string');
        if (empty($this->apiMethod)) {
            throw new Exception("Parameter apiMethod not set.");
        }
        $this->label = DataTablePostProcessor::getLabelFromRequest($_GET);
        if (!is_array($this->label)) {
            throw new Exception("Expected label to be an array, got instead: " . $this->label);
        }
        $this->label = Common::unsanitizeInputValue($this->label[0]);
        if ($this->label === '') {
            throw new Exception("Parameter label not set.");
        }
        $this->period = Common::getRequestVar('period', '', 'string');
        PeriodFactory::checkPeriodIsEnabled($this->period);
        $this->idSite = $idSite;
        $this->graphType = $graphType;
        if ($this->period != 'range') {
            // handle day, week, month and year: display last X periods
            $end = $date->toString();
            list($this->date, $lastN) = EvolutionViz::getDateRangeAndLastN($this->period, $end);
        }
        $this->segment = \Piwik\API\Request::getRawSegmentFromRequest();
        $this->loadEvolutionReport();
    }

Usage Example

 /**
  * The constructor
  * @param int $idSite
  * @param \Piwik\Date $date ($this->date from controller)
  */
 public function __construct($idSite, $date)
 {
     $this->metric = Common::getRequestVar('column', '', 'string');
     parent::__construct($idSite, $date);
 }