/**
  * Clear all permissions previously hidden with {@link add_hidden_permission}
  * 
  * @deprecated 4.0 Use "Permission.hidden_permissions" config setting instead
  */
 public static function clear_hidden_permissions()
 {
     Deprecation::notice('4.0', 'Use "Permission.hidden_permissions" config setting instead');
     Config::inst()->remove('Permission', 'hidden_permissions', Config::anything());
 }
Example #2
0
 /**
  * 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 Classname 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]);
         }
     }
 }
Example #3
0
	/**
	 * 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 $class
	 * @param string $extension Classname of an {@link Extension} subclass, without parameters
	 */
	public static function remove_extension($class, $extension) {
		Config::inst()->remove($class, 'extensions', Config::anything(), $extension);

		// unset singletons to avoid side-effects
		global $_SINGLETONS;
		$_SINGLETONS = array();

		// 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]);
		}
	}
Example #4
0
 /**
  * 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 $class
  * @param string $extension Classname of an {@link Extension} subclass, without parameters
  */
 public static function remove_extension($class, $extension)
 {
     Config::inst()->remove($class, 'extensions', Config::anything(), $extension);
     // 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]);
             unset(self::$extension_sources[$subclass]);
         }
     }
 }