original_string: public static function create_instance($plugin, $name, $config) {
          global $DB, $CFG;
          $new = (object)array(
              'plugin' => $plugin,
              'name'   => $name,
          );
          if (!portfolio_static_function($plugin, 'allows_multiple_instances')) {
              // check we don't have one already
              if ($DB->record_exists('portfolio_instance', array('plugin' => $plugin))) {
                  throw new portfolio_exception('multipleinstancesdisallowed', 'portfolio', '', $plugin);
              }
          }
          $newid = $DB->insert_record('portfolio_instance', $new);
          require_once($CFG->dirroot . '/portfolio/' . $plugin . '/lib.php');
          $classname = 'portfolio_plugin_'  . $plugin;
          $obj = new $classname($newid);
          $obj->set_config($config);
          $obj->save();
          return $obj;
      }
code: public static function create_instance($plugin, $name, $config) {
          global $DB, $CFG;
          $new = (object)array(
              'plugin' => $plugin,
              'name'   => $name,
          );
          if (!portfolio_static_function($plugin, 'allows_multiple_instances')) {
              // check we don't have one already
              if ($DB->record_exists('portfolio_instance', array('plugin' => $plugin))) {
                  throw new portfolio_exception('multipleinstancesdisallowed', 'portfolio', '', $plugin);
              }
          }
          $newid = $DB->insert_record('portfolio_instance', $new);
          require_once($CFG->dirroot . '/portfolio/' . $plugin . '/lib.php');
          $classname = 'portfolio_plugin_'  . $plugin;
          $obj = new $classname($newid);
          $obj->set_config($config);
          $obj->save();
          return $obj;
      }
code_tokens: public static function create_instance ( $ plugin , $ name , $ config ) { global $ DB , $ CFG ; $ new = ( object ) array ( 'plugin' => $ plugin , 'name' => $ name , ) ; if ( ! portfolio_static_function ( $ plugin , 'allows_multiple_instances' ) ) { // check we don't have one already if ( $ DB -> record_exists ( 'portfolio_instance' , array ( 'plugin' => $ plugin ) ) ) { throw new portfolio_exception ( 'multipleinstancesdisallowed' , 'portfolio' , '' , $ plugin ) ; } } $ newid = $ DB -> insert_record ( 'portfolio_instance' , $ new ) ; require_once ( $ CFG -> dirroot . '/portfolio/' . $ plugin . '/lib.php' ) ; $ classname = 'portfolio_plugin_' . $ plugin ; $ obj = new $ classname ( $ newid ) ; $ obj -> set_config ( $ config ) ; $ obj -> save ( ) ; return $ obj ; }
docstring: This function creates a new instance of a plugin
  saves it in the database, saves the config
  and returns it.
  You shouldn't need to override it
  unless you're doing something really funky
  
  @param string $plugin portfolio plugin to create
  @param string $name name of new instance
  @param array $config what the admin config form returned
  @return object subclass of portfolio_plugin_base
docstring_tokens: This function creates a new instance of a plugin saves it in the database saves the config and returns it . You shouldn t need to override it unless you re doing something really funky