You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
getVariableCount is hardly reliable when some blocks are cloned. The count before cloning is good, but it's possible not to apply the cloning the same way in all the differents parts.
Describe the solution you'd like
For variable count, use
public function getVariablesOccurences(){
$occurences = array('header' => array(), 'body' => 0, 'footer' => array());
$variables = $this->getVariablesForPart($this->tempDocumentMainPart);
$occurences['body'] = array_count_values($variables);
foreach ($this->tempDocumentHeaders as $header_index => $headerXML) {
$variables = $this->getVariablesForPart($headerXML);
$occurences['header'][$header_index] = array_count_values($variables);
}
foreach ($this->tempDocumentFooters as $footer_index => $footerXML) {
$variables = $this->getVariablesForPart($footerXML);
$occurences['footer'][$footer_index] = array_count_values($variables);
}
return $occurences;
}
Then modify getVariables to have the list of the variable and no more.
public function getVariables() {
$variables = $this->getVariablesForPart($this->tempDocumentMainPart);
foreach ($this->tempDocumentHeaders as $header_index => $headerXML) {
$variables = array_merge($variables, $this->getVariablesForPart($headerXML));
}
foreach ($this->tempDocumentFooters as $footer_index => $footerXML) {
$variables = array_merge($variables, $this->getVariablesForPart($footerXML));
}
return array_unique($variables);
}
Describe alternatives you've considered
Much PHP to write, and assumptions to the template content to be made.
Additional context
My goal is to define the way the template is filled from the template itself, and not from any PHP code.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
getVariableCount is hardly reliable when some blocks are cloned. The count before cloning is good, but it's possible not to apply the cloning the same way in all the differents parts.
Describe the solution you'd like
For variable count, use
public function getVariablesOccurences(){
$occurences = array('header' => array(), 'body' => 0, 'footer' => array());
$variables = $this->getVariablesForPart($this->tempDocumentMainPart);
$occurences['body'] = array_count_values($variables);
foreach ($this->tempDocumentHeaders as $header_index => $headerXML) {
$variables = $this->getVariablesForPart($headerXML);
$occurences['header'][$header_index] = array_count_values($variables);
}
foreach ($this->tempDocumentFooters as $footer_index => $footerXML) {
$variables = $this->getVariablesForPart($footerXML);
$occurences['footer'][$footer_index] = array_count_values($variables);
}
Then modify getVariables to have the list of the variable and no more.
public function getVariables() {
$variables = $this->getVariablesForPart($this->tempDocumentMainPart);
foreach ($this->tempDocumentHeaders as $header_index => $headerXML) {
$variables = array_merge($variables, $this->getVariablesForPart($headerXML));
}
foreach ($this->tempDocumentFooters as $footer_index => $footerXML) {
$variables = array_merge($variables, $this->getVariablesForPart($footerXML));
}
return array_unique($variables);
}
Describe alternatives you've considered
Much PHP to write, and assumptions to the template content to be made.
Additional context
My goal is to define the way the template is filled from the template itself, and not from any PHP code.
The text was updated successfully, but these errors were encountered: