/** * Enable one or more extensions. * * Extensions provide additional features to QueryPath. To enable and * extension, you can use this method. * * In this example, we enable the QPTPL extension: * @code * <?php * QueryPath::enable('\QueryPath\QPTPL'); * ?> * @endcode * * Note that the name is a fully qualified class name. * * We can enable more than one extension at a time like this: * * @code * <?php * $extensions = array('\QueryPath\QPXML', '\QueryPath\QPDB'); * QueryPath::enable($extensions); * ?> * @endcode * * @attention If you are not using an autoloader, you will need to * manually `require` or `include` the files that contain the * extensions. * * @param mixed $extensionNames * The name of an extension or an array of extension names. * QueryPath assumes that these are extension class names, * and attempts to register these as QueryPath extensions. */ public static function enable($extensionNames) { if (is_array($extensionNames)) { foreach ($extensionNames as $extension) { \QueryPath\ExtensionRegistry::extend($extension); } } else { \QueryPath\ExtensionRegistry::extend($extensionNames); } }
public function testExtend() { $this->assertFalse(ExtensionRegistry::hasExtension('\\QueryPath\\Tests\\StubExtensionThree')); ExtensionRegistry::extend('\\QueryPath\\Tests\\StubExtensionThree'); $this->assertTrue(ExtensionRegistry::hasExtension('\\QueryPath\\Tests\\StubExtensionThree')); }