original_string: public function add_store_instance($name, $plugin, array $configuration = array()) {
          if (array_key_exists($name, $this->configstores)) {
              throw new cache_exception('Duplicate name specificed for cache plugin instance. You must provide a unique name.');
          }
          $class = 'cachestore_'.$plugin;
          if (!class_exists($class)) {
              $plugins = core_component::get_plugin_list_with_file('cachestore', 'lib.php');
              if (!array_key_exists($plugin, $plugins)) {
                  throw new cache_exception('Invalid plugin name specified. The plugin does not exist or is not valid.');
              }
              $file = $plugins[$plugin];
              if (file_exists($file)) {
                  require_once($file);
              }
              if (!class_exists($class)) {
                  throw new cache_exception('Invalid cache plugin specified. The plugin does not contain the required class.');
              }
          }
          $reflection = new ReflectionClass($class);
          if (!$reflection->isSubclassOf('cache_store')) {
              throw new cache_exception('Invalid cache plugin specified. The plugin does not extend the required class.');
          }
          if (!$class::are_requirements_met()) {
              throw new cache_exception('Unable to add new cache plugin instance. The requested plugin type is not supported.');
          }
          $this->configstores[$name] = array(
              'name' => $name,
              'plugin' => $plugin,
              'configuration' => $configuration,
              'features' => $class::get_supported_features($configuration),
              'modes' => $class::get_supported_modes($configuration),
              'mappingsonly' => !empty($configuration['mappingsonly']),
              'class' => $class,
              'default' => false
          );
          if (array_key_exists('lock', $configuration)) {
              $this->configstores[$name]['lock'] = $configuration['lock'];
              unset($this->configstores[$name]['configuration']['lock']);
          }
          // Call instance_created()
          $store = new $class($name, $this->configstores[$name]['configuration']);
          $store->instance_created();
  
          $this->config_save();
          return true;
      }
code: public function add_store_instance($name, $plugin, array $configuration = array()) {
          if (array_key_exists($name, $this->configstores)) {
              throw new cache_exception('Duplicate name specificed for cache plugin instance. You must provide a unique name.');
          }
          $class = 'cachestore_'.$plugin;
          if (!class_exists($class)) {
              $plugins = core_component::get_plugin_list_with_file('cachestore', 'lib.php');
              if (!array_key_exists($plugin, $plugins)) {
                  throw new cache_exception('Invalid plugin name specified. The plugin does not exist or is not valid.');
              }
              $file = $plugins[$plugin];
              if (file_exists($file)) {
                  require_once($file);
              }
              if (!class_exists($class)) {
                  throw new cache_exception('Invalid cache plugin specified. The plugin does not contain the required class.');
              }
          }
          $reflection = new ReflectionClass($class);
          if (!$reflection->isSubclassOf('cache_store')) {
              throw new cache_exception('Invalid cache plugin specified. The plugin does not extend the required class.');
          }
          if (!$class::are_requirements_met()) {
              throw new cache_exception('Unable to add new cache plugin instance. The requested plugin type is not supported.');
          }
          $this->configstores[$name] = array(
              'name' => $name,
              'plugin' => $plugin,
              'configuration' => $configuration,
              'features' => $class::get_supported_features($configuration),
              'modes' => $class::get_supported_modes($configuration),
              'mappingsonly' => !empty($configuration['mappingsonly']),
              'class' => $class,
              'default' => false
          );
          if (array_key_exists('lock', $configuration)) {
              $this->configstores[$name]['lock'] = $configuration['lock'];
              unset($this->configstores[$name]['configuration']['lock']);
          }
          // Call instance_created()
          $store = new $class($name, $this->configstores[$name]['configuration']);
          $store->instance_created();
  
          $this->config_save();
          return true;
      }
code_tokens: public function add_store_instance ( $ name , $ plugin , array $ configuration = array ( ) ) { if ( array_key_exists ( $ name , $ this -> configstores ) ) { throw new cache_exception ( 'Duplicate name specificed for cache plugin instance. You must provide a unique name.' ) ; } $ class = 'cachestore_' . $ plugin ; if ( ! class_exists ( $ class ) ) { $ plugins = core_component :: get_plugin_list_with_file ( 'cachestore' , 'lib.php' ) ; if ( ! array_key_exists ( $ plugin , $ plugins ) ) { throw new cache_exception ( 'Invalid plugin name specified. The plugin does not exist or is not valid.' ) ; } $ file = $ plugins [ $ plugin ] ; if ( file_exists ( $ file ) ) { require_once ( $ file ) ; } if ( ! class_exists ( $ class ) ) { throw new cache_exception ( 'Invalid cache plugin specified. The plugin does not contain the required class.' ) ; } } $ reflection = new ReflectionClass ( $ class ) ; if ( ! $ reflection -> isSubclassOf ( 'cache_store' ) ) { throw new cache_exception ( 'Invalid cache plugin specified. The plugin does not extend the required class.' ) ; } if ( ! $ class :: are_requirements_met ( ) ) { throw new cache_exception ( 'Unable to add new cache plugin instance. The requested plugin type is not supported.' ) ; } $ this -> configstores [ $ name ] = array ( 'name' => $ name , 'plugin' => $ plugin , 'configuration' => $ configuration , 'features' => $ class :: get_supported_features ( $ configuration ) , 'modes' => $ class :: get_supported_modes ( $ configuration ) , 'mappingsonly' => ! empty ( $ configuration [ 'mappingsonly' ] ) , 'class' => $ class , 'default' => false ) ; if ( array_key_exists ( 'lock' , $ configuration ) ) { $ this -> configstores [ $ name ] [ 'lock' ] = $ configuration [ 'lock' ] ; unset ( $ this -> configstores [ $ name ] [ 'configuration' ] [ 'lock' ] ) ; } // Call instance_created() $ store = new $ class ( $ name , $ this -> configstores [ $ name ] [ 'configuration' ] ) ; $ store -> instance_created ( ) ; $ this -> config_save ( ) ; return true ; }
docstring: Adds a plugin instance.
  
  This function also calls save so you should redirect immediately, or at least very shortly after
  calling this method.
  
  @param string $name The name for the instance (must be unique)
  @param string $plugin The name of the plugin.
  @param array $configuration The configuration data for the plugin instance.
  @return bool
  @throws cache_exception
docstring_tokens: Adds a plugin instance .