original_string: public function set_mode_mappings(array $modemappings) {
          $mappings = array(
              cache_store::MODE_APPLICATION => array(),
              cache_store::MODE_SESSION => array(),
              cache_store::MODE_REQUEST => array(),
          );
          foreach ($modemappings as $mode => $stores) {
              if (!array_key_exists($mode, $mappings)) {
                  throw new cache_exception('The cache mode for the new mapping does not exist');
              }
              $sort = 0;
              foreach ($stores as $store) {
                  if (!array_key_exists($store, $this->configstores)) {
                      throw new cache_exception('The instance name for the new mapping does not exist');
                  }
                  if (array_key_exists($store, $mappings[$mode])) {
                      throw new cache_exception('This cache mapping already exists');
                  }
                  $mappings[$mode][] = array(
                      'store' => $store,
                      'mode' => $mode,
                      'sort' => $sort++
                  );
              }
          }
          $this->configmodemappings = array_merge(
              $mappings[cache_store::MODE_APPLICATION],
              $mappings[cache_store::MODE_SESSION],
              $mappings[cache_store::MODE_REQUEST]
          );
  
          $this->config_save();
          return true;
      }
code: public function set_mode_mappings(array $modemappings) {
          $mappings = array(
              cache_store::MODE_APPLICATION => array(),
              cache_store::MODE_SESSION => array(),
              cache_store::MODE_REQUEST => array(),
          );
          foreach ($modemappings as $mode => $stores) {
              if (!array_key_exists($mode, $mappings)) {
                  throw new cache_exception('The cache mode for the new mapping does not exist');
              }
              $sort = 0;
              foreach ($stores as $store) {
                  if (!array_key_exists($store, $this->configstores)) {
                      throw new cache_exception('The instance name for the new mapping does not exist');
                  }
                  if (array_key_exists($store, $mappings[$mode])) {
                      throw new cache_exception('This cache mapping already exists');
                  }
                  $mappings[$mode][] = array(
                      'store' => $store,
                      'mode' => $mode,
                      'sort' => $sort++
                  );
              }
          }
          $this->configmodemappings = array_merge(
              $mappings[cache_store::MODE_APPLICATION],
              $mappings[cache_store::MODE_SESSION],
              $mappings[cache_store::MODE_REQUEST]
          );
  
          $this->config_save();
          return true;
      }
code_tokens: public function set_mode_mappings ( array $ modemappings ) { $ mappings = array ( cache_store :: MODE_APPLICATION => array ( ) , cache_store :: MODE_SESSION => array ( ) , cache_store :: MODE_REQUEST => array ( ) , ) ; foreach ( $ modemappings as $ mode => $ stores ) { if ( ! array_key_exists ( $ mode , $ mappings ) ) { throw new cache_exception ( 'The cache mode for the new mapping does not exist' ) ; } $ sort = 0 ; foreach ( $ stores as $ store ) { if ( ! array_key_exists ( $ store , $ this -> configstores ) ) { throw new cache_exception ( 'The instance name for the new mapping does not exist' ) ; } if ( array_key_exists ( $ store , $ mappings [ $ mode ] ) ) { throw new cache_exception ( 'This cache mapping already exists' ) ; } $ mappings [ $ mode ] [ ] = array ( 'store' => $ store , 'mode' => $ mode , 'sort' => $ sort ++ ) ; } } $ this -> configmodemappings = array_merge ( $ mappings [ cache_store :: MODE_APPLICATION ] , $ mappings [ cache_store :: MODE_SESSION ] , $ mappings [ cache_store :: MODE_REQUEST ] ) ; $ this -> config_save ( ) ; return true ; }
docstring: Sets the mode mappings.
  
  These determine the default caches for the different modes.
  This function also calls save so you should redirect immediately, or at least very shortly after
  calling this method.
  
  @param array $modemappings
  @return bool
  @throws cache_exception
docstring_tokens: Sets the mode mappings .