Skip to content
This repository has been archived by the owner on Sep 28, 2018. It is now read-only.

Get all valid tags from document #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/Pdf/Docx/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,48 @@ public function setValue($search, $replace, $limit = -1)
);
}
}

/**
* Method: getAllTags
* =========================================================================
* Find all placeholders and return array.
*
* Paramters:
* -------------------------------------------------------------------------
* none
*
* Returns:
* -------------------------------------------------------------------------
* ```Array```
*/
public function getAllTags()
{

$tags = array();

$regex = '/\$\{([^}]+)\}/u';

foreach ($this->headerXMLs as $index => $headerXML)
{
if (preg_match_all($regex, $headerXML->asXml(), $matches)) {
$tags = array_merge($tags, $matches[1]);
}
}

if (preg_match_all($regex, $this->documentXML->asXml(), $matches)) {
$tags = array_merge($tags, $matches[1]);
}


foreach ($this->footerXMLs as $index => $footerXML)
{
if (preg_match_all($regex, $footerXML->asXml(), $matches)) {
$tags = array_merge($tags, $matches[1]);
}
}

return $tags;
}

/**
* Method: cloneBlock
Expand Down