Skip to content

Commit

Permalink
Make Twig dependency optional (#12)
Browse files Browse the repository at this point in the history
* Make Twig dependency optional

* Remove interfaces

* Move FileTrait methods to AbstractPdfBuilder

* Add MissingRequiredFieldException

* Make Gotenberg class final

* Use resolveFilePath

* Add ExceptionInterface

* Twig methods

* Rename renderPart method to withRenderedPart

* Rename GotenbergClient post method to call

* Remove arguments for required values from factory methods

* Remove addFile, rename htmlWrapper to wrapper

* Fix str_starts_with arguments order
  • Loading branch information
awurth committed Feb 22, 2024
1 parent f0a28c7 commit c448e19
Show file tree
Hide file tree
Showing 39 changed files with 1,198 additions and 975 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Validate composer.json and composer.lock
run: composer validate --strict

Expand Down Expand Up @@ -66,3 +71,6 @@ jobs:

- name: Run PHP CS Fixer
run: php vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation

- name: Run test suite
run: php vendor/bin/phpstan
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,24 @@
"symfony/mime": "^6.4 || ^7.0",
"symfony/string": "^6.4 || ^7.0",
"symfony/http-client": "^6.4 || ^7.0",
"symfony/filesystem": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0"
"symfony/filesystem": "^6.4 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^10.4",
"symfony/framework-bundle": "^6.4 || ^7.0",
"friendsofphp/php-cs-fixer": "^3.41",
"phpstan/phpstan": "^1.10",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-symfony": "^1.3",
"friendsofphp/php-cs-fixer": "^3.41"
"phpunit/phpunit": "^10.4",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"sort-packages": true
},
"suggest": {
"symfony/twig-bundle": "Allows you to use Twig to render templates into PDF"
}
}
17 changes: 9 additions & 8 deletions config/services.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

use Sensiolabs\GotenbergBundle\Client\GotenbergClient;
use Sensiolabs\GotenbergBundle\Client\GotenbergClientInterface;
use Sensiolabs\GotenbergBundle\Pdf\Gotenberg;
use Sensiolabs\GotenbergBundle\Pdf\GotenbergInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use function Symfony\Component\DependencyInjection\Loader\Configurator\abstract_arg;
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
Expand All @@ -13,20 +16,18 @@
$services->set('sensiolabs_gotenberg', Gotenberg::class)
->args([
service('sensiolabs_gotenberg.client'),
service('twig'),
abstract_arg('user configuration options'),
param('kernel.project_dir'),
service('twig')->nullOnInvalid(),
])
->public();
$services->alias(Gotenberg::class, 'sensiolabs_gotenberg')
->private();
->public()
->alias(GotenbergInterface::class, 'sensiolabs_gotenberg');

$services->set('sensiolabs_gotenberg.client', GotenbergClient::class)
->args([
abstract_arg('base_uri to gotenberg API'),
service('Symfony\Contracts\HttpClient\HttpClientInterface'),
service(HttpClientInterface::class),
])
->public();
$services->alias(GotenbergClient::class, 'sensiolabs_gotenberg.client')
->private();
->public()
->alias(GotenbergClientInterface::class, 'sensiolabs_gotenberg.client');
};
13 changes: 0 additions & 13 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,3 @@ parameters:
paths:
- 'src'
- 'tests'
ignoreErrors:
-
message: "#^Offset 'files' does not exist on array#"
count: 1
path: tests/Builder/OfficePdfBuilderTest.php
-
message: "#^Offset 'files' does not exist on array#"
count: 3
path: tests/Builder/TwigPdfBuilderTest.php
-
message: "#^Offset 'files' does not exist on array#"
count: 1
path: tests/Builder/MarkdownPdfBuilderTest.php
Loading

0 comments on commit c448e19

Please sign in to comment.