original_string: public function onModules( ModulesEvent $event )
      {
          $saved      = 0;
          $model      = $event->getTarget();
          $mapper     = $model->getMapper();
          $modules    = $event->getParams();
  
          foreach ( $modules as $name => $enabled )
          {
              if ( empty( $name ) )
              {
                  continue;
              }
  
              $name   = (string) $name;
              $module = $model->findByName( $name );
  
              if ( empty( $module ) )
              {
                  $module = $model->create( array(
                      'module'    => $name,
                      'enabled'   => $enabled,
                  ) );
              }
              else
              {
                  $module->enabled = $enabled;
              }
  
              $saved += $mapper->save( $module );
          }
  
          return $saved;
      }
code: public function onModules( ModulesEvent $event )
      {
          $saved      = 0;
          $model      = $event->getTarget();
          $mapper     = $model->getMapper();
          $modules    = $event->getParams();
  
          foreach ( $modules as $name => $enabled )
          {
              if ( empty( $name ) )
              {
                  continue;
              }
  
              $name   = (string) $name;
              $module = $model->findByName( $name );
  
              if ( empty( $module ) )
              {
                  $module = $model->create( array(
                      'module'    => $name,
                      'enabled'   => $enabled,
                  ) );
              }
              else
              {
                  $module->enabled = $enabled;
              }
  
              $saved += $mapper->save( $module );
          }
  
          return $saved;
      }
code_tokens: public function onModules ( ModulesEvent $ event ) { $ saved = 0 ; $ model = $ event -> getTarget ( ) ; $ mapper = $ model -> getMapper ( ) ; $ modules = $ event -> getParams ( ) ; foreach ( $ modules as $ name => $ enabled ) { if ( empty ( $ name ) ) { continue ; } $ name = ( string ) $ name ; $ module = $ model -> findByName ( $ name ) ; if ( empty ( $ module ) ) { $ module = $ model -> create ( array ( 'module' => $ name , 'enabled' => $ enabled , ) ) ; } else { $ module -> enabled = $ enabled ; } $ saved += $ mapper -> save ( $ module ) ; } return $ saved ; }
docstring: Default action on modules-set event
  
  @param   ModulesEvent    $event
  @return  int
docstring_tokens: Default action on modules - set event