original_string: public function add_lock_instance($name, $plugin, $configuration = array()) {
          if (array_key_exists($name, $this->configlocks)) {
              throw new cache_exception('Duplicate name specificed for cache lock instance. You must provide a unique name.');
          }
          $class = 'cachelock_'.$plugin;
          if (!class_exists($class)) {
              $plugins = core_component::get_plugin_list_with_file('cachelock', 'lib.php');
              if (!array_key_exists($plugin, $plugins)) {
                  throw new cache_exception('Invalid lock 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 lock plugin specified. The plugin does not contain the required class.');
              }
          }
          $reflection = new ReflectionClass($class);
          if (!$reflection->implementsInterface('cache_lock_interface')) {
              throw new cache_exception('Invalid lock plugin specified. The plugin does not implement the required interface.');
          }
          $this->configlocks[$name] = array_merge($configuration, array(
              'name' => $name,
              'type' => 'cachelock_'.$plugin,
              'default' => false
          ));
          $this->config_save();
      }
code: public function add_lock_instance($name, $plugin, $configuration = array()) {
          if (array_key_exists($name, $this->configlocks)) {
              throw new cache_exception('Duplicate name specificed for cache lock instance. You must provide a unique name.');
          }
          $class = 'cachelock_'.$plugin;
          if (!class_exists($class)) {
              $plugins = core_component::get_plugin_list_with_file('cachelock', 'lib.php');
              if (!array_key_exists($plugin, $plugins)) {
                  throw new cache_exception('Invalid lock 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 lock plugin specified. The plugin does not contain the required class.');
              }
          }
          $reflection = new ReflectionClass($class);
          if (!$reflection->implementsInterface('cache_lock_interface')) {
              throw new cache_exception('Invalid lock plugin specified. The plugin does not implement the required interface.');
          }
          $this->configlocks[$name] = array_merge($configuration, array(
              'name' => $name,
              'type' => 'cachelock_'.$plugin,
              'default' => false
          ));
          $this->config_save();
      }
code_tokens: public function add_lock_instance ( $ name , $ plugin , $ configuration = array ( ) ) { if ( array_key_exists ( $ name , $ this -> configlocks ) ) { throw new cache_exception ( 'Duplicate name specificed for cache lock instance. You must provide a unique name.' ) ; } $ class = 'cachelock_' . $ plugin ; if ( ! class_exists ( $ class ) ) { $ plugins = core_component :: get_plugin_list_with_file ( 'cachelock' , 'lib.php' ) ; if ( ! array_key_exists ( $ plugin , $ plugins ) ) { throw new cache_exception ( 'Invalid lock 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 lock plugin specified. The plugin does not contain the required class.' ) ; } } $ reflection = new ReflectionClass ( $ class ) ; if ( ! $ reflection -> implementsInterface ( 'cache_lock_interface' ) ) { throw new cache_exception ( 'Invalid lock plugin specified. The plugin does not implement the required interface.' ) ; } $ this -> configlocks [ $ name ] = array_merge ( $ configuration , array ( 'name' => $ name , 'type' => 'cachelock_' . $ plugin , 'default' => false ) ) ; $ this -> config_save ( ) ; }
docstring: Adds a new lock instance to the config file.
  
  @param string $name The name the user gave the instance. PARAM_ALHPANUMEXT
  @param string $plugin The plugin we are creating an instance of.
  @param string $configuration Configuration data from the config instance.
  @throws cache_exception
docstring_tokens: Adds a new lock instance to the config file .