/**
  * Remove an extension from a class.
  *
  * Keep in mind that this won't revert any datamodel additions
  * of the extension at runtime, unless its used before the
  * schema building kicks in (in your _config.php).
  * Doesn't remove the extension from any {@link Object}
  * instances which are already created, but will have an
  * effect on new extensions.
  * Clears any previously created singletons through {@link singleton()}
  * to avoid side-effects from stale extension information.
  *
  * @todo Add support for removing extensions with parameters
  *
  * @param string $extension class name of an {@link Extension} subclass, without parameters
  */
 public static function remove_extension($extension)
 {
     $class = get_called_class();
     Config::inst()->remove($class, 'extensions', Config::anything(), $extension);
     // remove any instances of the extension with parameters
     $config = Config::inst()->get($class, 'extensions');
     if ($config) {
         foreach ($config as $k => $v) {
             // extensions with parameters will be stored in config as
             // ExtensionName("Param").
             if (preg_match(sprintf("/^(%s)\\(/", preg_quote($extension, '/')), $v)) {
                 Config::inst()->remove($class, 'extensions', Config::anything(), $v);
             }
         }
     }
     Config::inst()->extraConfigSourcesChanged($class);
     // unset singletons to avoid side-effects
     Injector::inst()->unregisterAllObjects();
     // unset some caches
     $subclasses = ClassInfo::subclassesFor($class);
     $subclasses[] = $class;
     if ($subclasses) {
         foreach ($subclasses as $subclass) {
             unset(self::$classes_constructed[$subclass]);
             unset(self::$extra_methods[$subclass]);
         }
     }
 }