Skip to content

Commit 9cdca6b

Browse files
author
Dominic Tubach
committed
Move PhpWordTemplateProcessor to namespace Civi\Civioffice\PhpWord
1 parent 8252bf1 commit 9cdca6b

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

CRM/Civioffice/DocumentRendererType/LocalUnoconv/PhpWordTemplateProcessor.php Civi/Civioffice/PhpWord/PhpWordTemplateProcessor.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
declare(strict_types = 1);
1717

18-
use Civi\Civioffice\PhpWord\StyleMerger;
18+
namespace Civi\Civioffice\PhpWord;
19+
1920
use Civi\Civioffice\PhpWord\Util\TemplateUtil;
2021
use CRM_Civioffice_ExtensionUtil as E;
2122
use PhpOffice\PhpWord;
2223

23-
class CRM_Civioffice_DocumentRendererType_LocalUnoconv_PhpWordTemplateProcessor extends PhpWord\TemplateProcessor {
24+
class PhpWordTemplateProcessor extends PhpWord\TemplateProcessor {
2425

2526
/**
2627
* Replaces CiviCRM tokens with PhpWord macros (converts format from
@@ -116,8 +117,8 @@ public function replaceHtmlToken(string $macroVariable, string $renderedTokenMes
116117
$this->setElementsValue($macroVariable, $elements, TRUE);
117118
}
118119
}
119-
catch (Exception $exception) {
120-
throw new CRM_Core_Exception(
120+
catch (\Exception $exception) {
121+
throw new \CRM_Core_Exception(
121122
E::ts('Error loading/writing PhpWord document: %1', [1 => $exception->getMessage()]),
122123
$exception->getCode(),
123124
[],

Civi/Civioffice/PhpWord/PhpWordTokenReplacer.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ public function __construct(TokenProcessor $tokenProcessor) {
3232

3333
public function replaceTokens(string $inputFile, string $outputFile, TokenRow $tokenRow): void {
3434
try {
35-
$templateProcessor = new \CRM_Civioffice_DocumentRendererType_LocalUnoconv_PhpWordTemplateProcessor(
36-
$inputFile
37-
);
35+
$templateProcessor = new PhpWordTemplateProcessor($inputFile);
3836
}
3937
// @phpstan-ignore catch.neverThrown
4038
catch (\PhpOffice\PhpWord\Exception\Exception $e) {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright (C) 2024 SYSTOPIA GmbH
3+
* Copyright (C) 2025 SYSTOPIA GmbH
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as published by
@@ -17,15 +17,14 @@
1717

1818
declare(strict_types = 1);
1919

20-
namespace CRM\Civioffice\DocumentRendererType\LocalUnoconv;
20+
namespace Civi\Civioffice\PhpWord;
2121

22-
use Civi\Civioffice\DocumentRendererType\LocalUnoconv\TestablePhpWordTemplateProcessor;
2322
use PHPUnit\Framework\TestCase;
2423

2524
/**
26-
* @covers \CRM_Civioffice_DocumentRendererType_LocalUnoconv_PhpWordTemplateProcessor
25+
* @covers \Civi\Civioffice\PhpWord\PhpWordTemplateProcessor
2726
*/
28-
final class CRM_Civioffice_DocumentRendererType_LocalUnoconv_PhpWordTemplateProcessorTest extends TestCase {
27+
final class PhpWordTemplateProcessorTest extends TestCase {
2928

3029
public function testReplaceSimple(): void {
3130
$mainPart = <<<EOD
+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright (C) 2024 SYSTOPIA GmbH
3+
* Copyright (C) 2025 SYSTOPIA GmbH
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as published by
@@ -17,13 +17,9 @@
1717

1818
declare(strict_types = 1);
1919

20-
namespace Civi\Civioffice\DocumentRendererType\LocalUnoconv;
20+
namespace Civi\Civioffice\PhpWord;
2121

22-
/**
23-
* phpcs:disable Generic.Files.LineLength.TooLong
24-
*/
25-
final class TestablePhpWordTemplateProcessor extends \CRM_Civioffice_DocumentRendererType_LocalUnoconv_PhpWordTemplateProcessor {
26-
// phpcs:enable
22+
final class TestablePhpWordTemplateProcessor extends PhpWordTemplateProcessor {
2723

2824
/**
2925
* @param list<string> $headers

0 commit comments

Comments
 (0)