lithium\core\Libraries::remove PHP Method

remove() public static method

Removes a registered library, and unregister's the library's autoloader, if it has one.
public static remove ( mixed $name )
$name mixed A string or array of library names indicating the libraries you wish to remove, i.e. `'app'` or `'lithium'`. This can also be used to unload plugins by name.
    public static function remove($name)
    {
        foreach ((array) $name as $library) {
            if (isset(static::$_configurations[$library])) {
                if (static::$_configurations[$library]['loader']) {
                    spl_autoload_unregister(static::$_configurations[$library]['loader']);
                }
                unset(static::$_configurations[$library]);
            }
        }
    }

Usage Example

 public function testConfig()
 {
     $oldConfig = Libraries::get('li3_facebook');
     Libraries::remove('li3_facebook');
     Libraries::add('li3_facebook');
     FacebookProxy::$_autoConfigure = false;
     FacebookProxy::__init();
     $this->assertEqual(FacebookProxy::config(), array(), 'config should be empty.');
     $this->assertEqual(FacebookProxy::config(array()), array(), 'config should be empty.');
     //check ignoring
     FacebookProxy::reset();
     $result = FacebookProxy::config(array('foo'));
     $this->assertTrue($result, array(), 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), array(), 'config should be empty');
     //check ingoring vs. existing but unset associations
     FacebookProxy::reset();
     $result = FacebookProxy::config(array('appId'));
     $this->assertTrue($result, array(), 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), array(), 'config should be empty');
     //check valid Settings
     FacebookProxy::reset();
     $sampleConfig = array('appId' => 'hello');
     $result = FacebookProxy::config($sampleConfig);
     $this->assertTrue($result, 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), $sampleConfig, 'config should not be empty');
     //check vs. complete Settings
     FacebookProxy::reset();
     $result = FacebookProxy::config($this->_mockDefaults);
     $this->assertTrue($result, 'config should return true');
     $this->assertIdentical(FacebookProxy::config(), $this->_mockDefaults, 'config should not be empty');
     Libraries::remove('li3_facebook');
     Libraries::add('li3_facebook', $oldConfig);
     //FaceBookProxy::foo();
     //die(print_r(array($result,FacebookProxy::config()),true));
 }
All Usage Examples Of lithium\core\Libraries::remove