public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
    {
        if (empty($pluginName) || empty($componentClassSimpleName)) {
            Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
                __FUNCTION__, $pluginName, $componentClassSimpleName);

            return null;
        }

        $plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
        if (empty($plugin)) {
            return null;
        }

        $subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
        $desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;

        $components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
        foreach ($components as $class) {
            if ($class == $desiredComponentClass) {
                return new $class();
            }
        }

        Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
            __FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);

        return null;
    }
public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
    {
        if (empty($pluginName) || empty($componentClassSimpleName)) {
            Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
                __FUNCTION__, $pluginName, $componentClassSimpleName);

            return null;
        }

        $plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
        if (empty($plugin)) {
            return null;
        }

        $subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
        $desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;

        $components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
        foreach ($components as $class) {
            if ($class == $desiredComponentClass) {
                return new $class();
            }
        }

        Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
            __FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);

        return null;
    }
public static function factory ( $ pluginName , $ componentClassSimpleName , $ componentTypeClass ) { if ( empty ( $ pluginName ) || empty ( $ componentClassSimpleName ) ) { Log :: debug ( "ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)" , __FUNCTION__ , $ pluginName , $ componentClassSimpleName ) ; return null ; } $ plugin = self :: getActivatedPlugin ( __FUNCTION__ , $ pluginName ) ; if ( empty ( $ plugin ) ) { return null ; } $ subnamespace = $ componentTypeClass :: COMPONENT_SUBNAMESPACE ; $ desiredComponentClass = 'Piwik\\Plugins\\' . $ pluginName . '\\' . $ subnamespace . '\\' . $ componentClassSimpleName ; $ components = $ plugin -> findMultipleComponents ( $ subnamespace , $ componentTypeClass ) ; foreach ( $ components as $ class ) { if ( $ class == $ desiredComponentClass ) { return new $ class ( ) ; } } Log :: debug ( "ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s'])." , __FUNCTION__ , $ pluginName , $ componentClassSimpleName , $ componentTypeClass ) ; return null ; }
Create a component instance that exists within a specific plugin. Uses the component's
unqualified class name and expected base type.

This method will only create a class if it is located within the component type's
associated subdirectory.

@param string $pluginName The name of the plugin the component is expected to belong to,
eg, `'DevicesDetection'`.
@param string $componentClassSimpleName The component's class name w/o namespace, eg,
`"GetKeywords"`.
@param string $componentTypeClass The fully qualified class name of the component type, eg,
`"Piwik\Plugin\Report"`.
@return mixed|null A new instance of the desired component or null if not found. If the
plugin is not loaded or activated or the component is not located in
in the sub-namespace specified by `$componentTypeClass::COMPONENT_SUBNAMESPACE`,
this method will return null.
Create a component instance that exists within a specific plugin . Uses the component s unqualified class name and expected base type .