Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
endelwar committed Jan 16, 2023
2 parents d1ab190 + 950195c commit 8fa9ead
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 208 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,16 @@ jobs:
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
include:
- description: 'Symfony 5.4'
php: '7.4'
symfony: 5.4.*
composer_option: '--prefer-lowest'
- description: 'Symfony 6.0'
php: '8.0'
symfony: 6.0.*
- description: 'Symfony 6.1'
php: '8.1'
symfony: 6.1.*
- description: 'Symfony 5.4'
php: '8.2'
symfony: 5.4.*
- description: 'Symfony 6.2'
php: '8.2'
symfony: 6.2.*
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 2.0.0 - 2023-01-16
### Changed
- Drop support for unsupported php-weasyprint versions
- Bump Symfony 6 support to >= 6.2

### Removed
- Remove deprecate Image response

## 1.4.0 - 2023-01-16
### Added
- Add support for php-weasyprint 0.13
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ weasyprint:
enabled: true
binary: /usr/local/bin/weasyprint
options: []
image:
enabled: true
binary: /usr/local/bin/weasyprint
options: []
```
If you want to change temporary folder which is ```sys_get_temp_dir()``` by default, you can use
Expand All @@ -59,10 +55,9 @@ weasyprint:

## Usage

The bundle registers two services:
The bundle registers one service:

- the `weasyprint.pdf` service allows you to generate pdf files.
- the `weasyprint.image` service allows you to generate images (works only with WeasyPrint 52.5 or lower);

### Generate a pdf document from a URL

Expand Down Expand Up @@ -134,4 +129,4 @@ class SomeController extends AbstractController
## Credits

WeasyPrintBundle and [PhpWeasyPrint](https://github.com/pontedilana/php-weasyprint) has been developed by [Pontedilana](https://www.pontedilana.it/).
SnappyBundle has been developed by [KnpLabs](https://knplabs.com).
SnappyBundle has been developed by [KnpLabs](https://knplabs.com).
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
],
"require": {
"php": "7.4.* || 8.0.* || 8.1.* || 8.2.*",
"pontedilana/php-weasyprint": "^0.10 || ^0.11 || ^0.12 || ^0.13 || ^1.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0"
"pontedilana/php-weasyprint": "^1.0",
"symfony/config": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2"
},
"require-dev": {
"doctrine/annotations": "^1.11",
Expand All @@ -31,10 +31,10 @@
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0",
"symfony/validator": "^5.4 || ^6.0",
"symfony/yaml": "^5.4 || ^6.0"
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^5.4 || ^6.2",
"symfony/validator": "^5.4 || ^6.2",
"symfony/yaml": "^5.4 || ^6.2"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 0 additions & 19 deletions config/image.xml

This file was deleted.

18 changes: 0 additions & 18 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->end()
->end()
->arrayNode('image')
->canBeEnabled()
->children()
->booleanNode('enabled')->defaultFalse()->end()
->scalarNode('binary')->defaultValue('weasyprint')->end()
->arrayNode('options')
->performNoDeepMerging()
->useAttributeAsKey('name')
->beforeNormalization()
->always($fixOptionKeys)
->end()
->prototype('scalar')->end()
->end()
->arrayNode('env')
->prototype('scalar')->end()
->end()
->end()
->end()
->end();

return $treeBuilder;
Expand Down
17 changes: 0 additions & 17 deletions src/DependencyInjection/WeasyprintExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,5 @@ public function load(array $configs, ContainerBuilder $container): void
->addMethodCall('setTimeout', [$config['process_timeout']]);
}
}

if ($config['image']['enabled']) {
$loader->load('image.xml');

$container->setParameter('weasyprint.image.binary', $config['image']['binary']);
$container->setParameter('weasyprint.image.options', $config['image']['options']);
$container->setParameter('weasyprint.image.env', $config['image']['env']);

if (!empty($config['temporary_folder'])) {
$container->findDefinition('weasyprint.image')
->addMethodCall('setTemporaryFolder', [$config['temporary_folder']]);
}
if (!empty($config['process_timeout'])) {
$container->findDefinition('weasyprint.image')
->addMethodCall('setTimeout', [$config['process_timeout']]);
}
}
}
}
20 changes: 0 additions & 20 deletions src/WeasyPrint/Response/ImageResponse.php

This file was deleted.

44 changes: 0 additions & 44 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ public function dataForProcessedConfiguration(): array
'options' => [],
'env' => [],
],
'image' => [
'enabled' => false,
'binary' => 'weasyprint',
'options' => [],
'env' => [],
],
],
],
[
Expand All @@ -54,12 +48,6 @@ public function dataForProcessedConfiguration(): array
'options' => ['foo' => 'bar'],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => '/path/to/weasyprint',
'options' => ['baz' => 'bat', 'baf' => 'bag'],
'env' => [],
],
],
[
'pdf' => [
Expand All @@ -75,12 +63,6 @@ public function dataForProcessedConfiguration(): array
'options' => ['bak' => 'bap'],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => '/path/to/weasyprint',
'options' => ['baz' => 'bat', 'baf' => 'bag'],
'env' => [],
],
],
],
[
Expand All @@ -94,12 +76,6 @@ public function dataForProcessedConfiguration(): array
'options' => [],
'env' => [],
],
'image' => [
'enabled' => false,
'binary' => 'weasyprint',
'options' => [],
'env' => [],
],
],
],
[
Expand All @@ -111,12 +87,6 @@ public function dataForProcessedConfiguration(): array
],
'env' => [],
],
'image' => [
'options' => [
'bag-baf' => 'bak',
],
'env' => [],
],
],
],
[
Expand All @@ -128,14 +98,6 @@ public function dataForProcessedConfiguration(): array
],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => 'weasyprint',
'options' => [
'bag-baf' => 'bak',
],
'env' => [],
],
],
],
[
Expand All @@ -152,12 +114,6 @@ public function dataForProcessedConfiguration(): array
'options' => [],
'env' => [],
],
'image' => [
'enabled' => false,
'binary' => 'weasyprint',
'options' => [],
'env' => [],
],
],
],
];
Expand Down
24 changes: 0 additions & 24 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pontedilana\WeasyprintBundle\Tests;

use PHPUnit\Framework\TestCase;
use Pontedilana\PhpWeasyPrint\Image;
use Pontedilana\PhpWeasyPrint\Pdf;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -40,11 +39,6 @@ public function testServiceIsAvailableOutOfTheBox(): void

$this->assertInstanceof(Pdf::class, $pdf);
$this->assertEquals('weasyprint', $pdf->getBinary());

$this->assertFalse($container->has('weasyprint.image'), 'The image service is available.');

$this->expectException(ServiceNotFoundException::class);
$image = $container->get('weasyprint.image');
}

public function testChangeBinaries(): void
Expand All @@ -60,13 +54,6 @@ public function testChangeBinaries(): void

$this->assertInstanceof(Pdf::class, $pdf);
$this->assertEquals('/custom/binary/for/weasyprint', $pdf->getBinary());

$this->assertTrue($container->has('weasyprint.image'));

$image = $container->get('weasyprint.image');

$this->assertInstanceof(Image::class, $image);
$this->assertEquals('/custom/binary/for/weasyprint', $image->getBinary());
}

public function testChangeTemporaryFolder(): void
Expand All @@ -90,15 +77,4 @@ public function testDisablePdf(): void

$this->assertFalse($container->has('weasyprint.pdf'), 'The pdf service is NOT available.');
}

public function testEnableImage(): void
{
$this->kernel->setConfigurationFilename(__DIR__ . '/fixtures/config/enable_image.yml');
$this->kernel->boot();

$container = $this->kernel->getContainer();

$this->assertTrue($container->has('weasyprint.pdf'), 'The pdf service is available.');
$this->assertTrue($container->has('weasyprint.image'), 'The image service is NOT available.');
}
}
40 changes: 0 additions & 40 deletions tests/WeasyPrint/Response/ImageResponseTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/WeasyPrint/Response/WeasyPrintResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class WeasyPrintResponseTest extends TestCase
public function testExceptionMessage(): void
{
try {
new WeasyPrintResponse('', 'test.png', 'image/png', 'foo');
new WeasyPrintResponse('', 'test.pdf', 'application/pdf', 'foo');
} catch (\InvalidArgumentException $e) {
$this->assertSame('Expected one of the following directives: "inline", "attachment", but "foo" given.', $e->getMessage());
}
Expand Down
2 changes: 0 additions & 2 deletions tests/fixtures/config/change_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ imports:
weasyprint:
pdf:
binary: /custom/binary/for/weasyprint
image:
binary: /custom/binary/for/weasyprint

0 comments on commit 8fa9ead

Please sign in to comment.