getManifest(); } /** * Make this config available to be modified * * @return MutableConfigCollectionInterface */ public static function modify() { $instance = static::inst(); if ($instance instanceof MutableConfigCollectionInterface) { return $instance; } // By default nested configs should become mutable $instance = static::nest(); if ($instance instanceof MutableConfigCollectionInterface) { return $instance; } throw new InvalidArgumentException("Nested config could not be made mutable"); } /** * Make the newly active {@link Config} be a copy of the current active * {@link Config} instance. * * You can then make changes to the configuration by calling update and * remove on the new value returned by {@link Config::inst()}, and then discard * those changes later by calling unnest. * * @return ConfigCollectionInterface Active config */ public static function nest() { // Clone current config and nest $new = self::inst()->nest(); ConfigLoader::inst()->pushManifest($new); return $new; } /** * Change the active Config back to the Config instance the current active * Config object was copied from. * * @return ConfigCollectionInterface */ public static function unnest() { // Unnest unless we would be left at 0 manifests $loader = ConfigLoader::inst(); if ($loader->countManifests() <= 1) { user_error( "Unable to unnest root Config, please make sure you don't have mis-matched nest/unnest", E_USER_WARNING ); } else { $loader->popManifest(); } return static::inst(); } /** * Get an accessor that returns results by class by default. * * Shouldn't be overridden, since there might be many Config_ForClass instances already held in the wild. Each * Config_ForClass instance asks the current_instance of Config for the actual result, so override that instead * * @param string $class * @return Config_ForClass */ public static function forClass($class) { return new Config_ForClass($class); } }