original_string: public function set_definition_mappings($definition, $mappings) {
          if (!array_key_exists($definition, $this->configdefinitions)) {
              throw new coding_exception('Invalid definition name passed when updating mappings.');
          }
          foreach ($mappings as $store) {
              if (!array_key_exists($store, $this->configstores)) {
                  throw new coding_exception('Invalid store name passed when updating definition mappings.');
              }
          }
          foreach ($this->configdefinitionmappings as $key => $mapping) {
              if ($mapping['definition'] == $definition) {
                  unset($this->configdefinitionmappings[$key]);
              }
          }
          $sort = count($mappings);
          foreach ($mappings as $store) {
              $this->configdefinitionmappings[] = array(
                  'store' => $store,
                  'definition' => $definition,
                  'sort' => $sort
              );
              $sort--;
          }
  
          $this->config_save();
      }
code: public function set_definition_mappings($definition, $mappings) {
          if (!array_key_exists($definition, $this->configdefinitions)) {
              throw new coding_exception('Invalid definition name passed when updating mappings.');
          }
          foreach ($mappings as $store) {
              if (!array_key_exists($store, $this->configstores)) {
                  throw new coding_exception('Invalid store name passed when updating definition mappings.');
              }
          }
          foreach ($this->configdefinitionmappings as $key => $mapping) {
              if ($mapping['definition'] == $definition) {
                  unset($this->configdefinitionmappings[$key]);
              }
          }
          $sort = count($mappings);
          foreach ($mappings as $store) {
              $this->configdefinitionmappings[] = array(
                  'store' => $store,
                  'definition' => $definition,
                  'sort' => $sort
              );
              $sort--;
          }
  
          $this->config_save();
      }
code_tokens: public function set_definition_mappings ( $ definition , $ mappings ) { if ( ! array_key_exists ( $ definition , $ this -> configdefinitions ) ) { throw new coding_exception ( 'Invalid definition name passed when updating mappings.' ) ; } foreach ( $ mappings as $ store ) { if ( ! array_key_exists ( $ store , $ this -> configstores ) ) { throw new coding_exception ( 'Invalid store name passed when updating definition mappings.' ) ; } } foreach ( $ this -> configdefinitionmappings as $ key => $ mapping ) { if ( $ mapping [ 'definition' ] == $ definition ) { unset ( $ this -> configdefinitionmappings [ $ key ] ) ; } } $ sort = count ( $ mappings ) ; foreach ( $ mappings as $ store ) { $ this -> configdefinitionmappings [ ] = array ( 'store' => $ store , 'definition' => $ definition , 'sort' => $ sort ) ; $ sort -- ; } $ this -> config_save ( ) ; }
docstring: Sets the mappings for a given definition.
  
  @param string $definition
  @param array $mappings
  @throws coding_exception
docstring_tokens: Sets the mappings for a given definition .