original_string: public function factory($module, $action)
      {
          if (empty($module) || empty($action)) {
              return;
          }
  
          try {
              if (!$this->pluginManager->isPluginActivated($module)) {
                  return;
              }
  
              $plugin = $this->pluginManager->getLoadedPlugin($module);
          } catch (\Exception $e) {
              // we are not allowed to use possible widgets, plugin is not active
              return;
          }
  
          /** @var Widget[] $widgetContainer */
          $widgets = $plugin->findMultipleComponents('Widgets', 'Piwik\\Widget\\Widget');
  
          foreach ($widgets as $widgetClass) {
              $config = $this->getWidgetConfigForClassName($widgetClass);
              if ($config->getAction() === $action) {
                  $config->checkIsEnabled();
                  return StaticContainer::get($widgetClass);
              }
          }
      }
code: public function factory($module, $action)
      {
          if (empty($module) || empty($action)) {
              return;
          }
  
          try {
              if (!$this->pluginManager->isPluginActivated($module)) {
                  return;
              }
  
              $plugin = $this->pluginManager->getLoadedPlugin($module);
          } catch (\Exception $e) {
              // we are not allowed to use possible widgets, plugin is not active
              return;
          }
  
          /** @var Widget[] $widgetContainer */
          $widgets = $plugin->findMultipleComponents('Widgets', 'Piwik\\Widget\\Widget');
  
          foreach ($widgets as $widgetClass) {
              $config = $this->getWidgetConfigForClassName($widgetClass);
              if ($config->getAction() === $action) {
                  $config->checkIsEnabled();
                  return StaticContainer::get($widgetClass);
              }
          }
      }
code_tokens: public function factory ( $ module , $ action ) { if ( empty ( $ module ) || empty ( $ action ) ) { return ; } try { if ( ! $ this -> pluginManager -> isPluginActivated ( $ module ) ) { return ; } $ plugin = $ this -> pluginManager -> getLoadedPlugin ( $ module ) ; } catch ( \ Exception $ e ) { // we are not allowed to use possible widgets, plugin is not active return ; } /** @var Widget[] $widgetContainer */ $ widgets = $ plugin -> findMultipleComponents ( 'Widgets' , 'Piwik\\Widget\\Widget' ) ; foreach ( $ widgets as $ widgetClass ) { $ config = $ this -> getWidgetConfigForClassName ( $ widgetClass ) ; if ( $ config -> getAction ( ) === $ action ) { $ config -> checkIsEnabled ( ) ; return StaticContainer :: get ( $ widgetClass ) ; } } }
docstring: Get the widget defined by the given module and action.
  
  @param string $module Aka plugin name, eg 'CoreHome'
  @param string $action An action eg 'renderMe'
  @return Widget|null
  @throws \Exception Throws an exception if the widget is not enabled.
docstring_tokens: Get the widget defined by the given module and action .