public function test_factory_shouldNotFindAComponent_IfPluginIsLoadedButNotActivated() { PluginManager::getInstance()->loadPlugin('ExampleReport'); $module = 'ExampleReport'; $action = 'GetExampleReport'; $report = ComponentFactory::factory($module, $action, self::REPORT_CLASS_NAME); $this->assertNull($report); }
/** * Finds a top level report that provides stats for a specific Dimension. * * @param Dimension $dimension The dimension whose report we're looking for. * @return Report|null The * @api */ public static function getForDimension(Dimension $dimension) { return ComponentFactory::getComponentIf(__CLASS__, $dimension->getModule(), function (Report $report) use($dimension) { return !$report->isSubtableReport() && $report->getDimension() && $report->getDimension()->getId() == $dimension->getId(); }); }
/** * Creates a Dimension instance from a string ID (see {@link getId()}). * * @param string $dimensionId See {@link getId()}. * @return Dimension|null The created instance or null if there is no Dimension for * $dimensionId or if the plugin that contains the Dimension is * not loaded. * @api */ public static function factory($dimensionId) { list($module, $dimension) = explode('.', $dimensionId); return ComponentFactory::factory($module, $dimension, __CLASS__); }
public function test_getComponentIf_shouldSearchThroughAllPlugins_IfNoPluginNameIsSupplied() { PluginManager::getInstance()->loadPlugins(array('ExampleReport', 'Referrers')); $reports = array(); ComponentFactory::getComponentIf(self::REPORT_CLASS_NAME, null, function (Report $report) use(&$reports) { $reports[] = $report; }); $this->assertGreaterThan(1, count($reports)); }
/** * Get an instance of a specific report belonging to the given module and having the given action. * @param string $module * @param string $action * @return null|\Piwik\Plugin\Report * @api */ public static function factory($module, $action) { return ComponentFactory::factory($module, ucfirst($action), __CLASS__); }