Skip to content
Thomas Weinert edited this page Jul 12, 2018 · 3 revisions

Functions

FluentDOM provides several functions that act as shortcuts to access logic. These are static calls, so they introduce hard dependencies into your source, but they can be really convenient.

Most of them are static functions on the abstract class FluentDOM.

FluentDOM() / FluentDOM::Query()

This function return a FluentDOM\Query instance. You can provide a source an a content type as arguments.

// global function
$fd = FluentDOM('<xml/>', 'xml');
// static function
$fd = FluentDOM::Query('<xml/>', 'xml');
// creating an instance
$fd = new FluentDOM\Query('<xml/>', 'xml');

FluentDOM::QueryCss()

Basically the same as FluentDOM::Query(). But it sets callback that is used to transform the provided selector arguments from CSS to XPath. You need to have a transformation library installed.

FluentDOM::create()

(FluentDOM >= 5.1)

Returns an instance of FluentDOM\Nodes\Creator. The arguments are optional.

// static call
$_ = FluentDOM::create('1.0', 'utf-8');
// creating an instance
$_ = new FluentDOM\Nodes\Creator('1.0', 'utf-8');

FluentDOM::load()

(FluentDOM >= 5.2)

Returns a FluentDOM\DOM\Document() instance. This uses the loaders, so you can load formats like JSON, too. FluentDOM::setLoader() even allows you to define a specific loader if really necessary.

// static call
$document = FluentDOM::load($json, 'json');
// creating an instance
$loader = new FluentDOM\Loader\Json();
$document = $loader->load($json, 'json');
Clone this wiki locally