Merge
Merge other document into current document.
Description
$this Document::merge(Document $newDoc [, int $mode = Document::MERGE_CONFIG])
Parameters
$newDoc
: The document to be merged in.$mode
: Mode to be used while merging. Default modeDocument::MERGE_CONFIG
Modes
| Mode Constant | Mode Description | |-----------------------|------------------------------------------------------------------------------| | MERGECONFIG | Merge only config. | | MERGECONTENTREPLACE | Merge only content. Replaces current content with that from merging document | | MERGECONTENTAPPEND | Merge only content. Appends content from merging document to current one. | | MERGEALLREPLACE | Merge both config and content. Same as `MERGECONTENTREPLACE`. | | MERGEALLAPPEND | Merge both config and content. Same as `MERGECONTENT_APPEND`. |
Return Value
- Current instance of document (
$this
). Makes Method Chainable.
Usage
$document = new Document('Lorem Ipsum dol sidur.....', ['title'=> 'Not A Random Title', 'layout' => 'grid']);
$newDoc = new Document('Lorem Ipsum.....', ['title'=> 'Random Title', 'category' => 'just another category']);
$document->merge($newDoc);
$document->getConfig();
//['title'=> 'Random Title', 'layout'=> 'grid', 'category' => 'just another category']