racztiborzoltan / dom-operation-queue
DOM Operation Queue
1.0.1
2020-11-09 00:08 UTC
Requires
- php: ^7.1|^8.0
Requires (Dev)
- phpunit/phpunit: ^7.0|^8.0|^9.0
This package is auto-updated.
Last update: 2024-11-09 11:49:25 UTC
README
List of DOM Operations with optional priority.
Examples
Create your DOM Operation class:
class TestDomOperation implements \DomOperationQueue\DomOperationInterface { public function executeDomOperation(\DOMDocument $dom_document): \DOMDocument { // // define your dom manipulation // return $dom_document; } // // ... This is your code area! :) // }
You will need an \DOMDocument object
$dom_document = new DOMDocument(); // load content into dom. For example: $dom_document->loadXML('<root></root>');
Using the list
$list = new DomOperationQueue(); $operation_1 = new TestDomOperation(); // add operation to list with priority or without priority: $list->add(new TestDomOperation()); $list->add(new TestDomOperation(), 10); // remove operation: // $list->remove($removable_operation_object); // remove operations by priority: $list->removeByPriority(15); // execute operations on an \DOMDocument object: $list->execute($dom_document); // or: $dom_document = $list->execute($dom_document);
Using the modified \DOMDocument
// for example: $dom_document->formatOutput = true; echo $dom_document->saveXML($dom_document->documentElement);