Piwik\Plugin\ReportsProvider::factory PHP Method

factory() public static method

Get an instance of a specific report belonging to the given module and having the given action.
public static factory ( string $module, string $action ) : null | Report
$module string
$action string
return null | Report
    public static function factory($module, $action)
    {
        $listApiToReport = self::getMapOfModuleActionsToReport();
        $api = $module . '.' . ucfirst($action);
        if (!array_key_exists($api, $listApiToReport)) {
            return null;
        }
        $klassName = $listApiToReport[$api];
        return new $klassName();
    }

Usage Example

Example #1
0
 /**
  * Constructor.
  */
 public function __construct($apiModule, $apiMethod, $request)
 {
     $this->apiModule = $apiModule;
     $this->apiMethod = $apiMethod;
     $this->setRequest($request);
     $this->report = ReportsProvider::factory($apiModule, $apiMethod);
     $this->apiInconsistencies = new Inconsistencies();
     $this->setFormatter(new Formatter());
 }
All Usage Examples Of Piwik\Plugin\ReportsProvider::factory