Skip to content

Commit ba38057

Browse files
committed
Support typeset.sh v0.19
1 parent 938b0bb commit ba38057

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/pdf-parser/var
77
/.phpunit.result.cache
88
.php_cs.cache
9-
composer.lock
9+
composer.lock
10+
/.php-cs-fixer.cache

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
->in(__DIR__ . '/src')
66
;
77

8-
return PhpCsFixer\Config::create()
9-
->setRules([
10-
'@PSR2' => true,
8+
$config = new PhpCsFixer\Config();
9+
return $config->setRules([
1110
'@Symfony' => true,
12-
//'strict_param' => true,
13-
'cast_spaces' => ['space' => 'none'],
14-
'array_syntax' => ['syntax' => 'short'],
15-
'no_unneeded_curly_braces' => false,
16-
'no_unset_on_property' => false,
17-
'php_unit_method_casing' => ['case' => 'snake_case'],
18-
'phpdoc_align' => ['align' => 'left'],
11+
12+
/*
13+
* Personal opinion.
14+
*/
1915
'yoda_style' => false,
16+
'phpdoc_align' => ['align' => 'left'],
17+
'php_unit_method_casing' => ['case' => 'snake_case'],
18+
2019
])
2120
->setFinder($finder)
22-
;
21+
;

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"minimum-stability": "stable",
1717
"require": {
1818
"laravel/framework": "^7.0 || ^8.0",
19-
"typesetsh/typesetsh": "^0.18"
19+
"typesetsh/typesetsh": "^0.19"
2020
},
2121
"require-dev": {
22-
"friendsofphp/php-cs-fixer": "^2.16"
22+
"friendsofphp/php-cs-fixer": "~v3.4.0"
2323
},
2424
"autoload": {
2525
"psr-4": {

config/typesetsh.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
|
2424
| The base directory to use for relative paths.
2525
|
26+
| Use public_path() to convert any /some-file.css to your public directory.
27+
| Use an empty '' string if you prefer absolute paths in your source.
28+
|
29+
| Make sure the paths you pick are inside the allowed_directories.
2630
*/
2731

28-
'base_dir' => '/',
32+
'base_dir' => '',
2933

3034
/*
3135
|--------------------------------------------------------------------------

src/ServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class ServiceProvider extends Support\ServiceProvider implements Contracts\Support\DeferrableProvider
1515
{
16-
const CONFIG_PATH = __DIR__.'/../config/typesetsh.php';
16+
public const CONFIG_PATH = __DIR__.'/../config/typesetsh.php';
1717

1818
/**
1919
* Register the service provider.
@@ -39,9 +39,9 @@ protected function registerPdfRenderer(): void
3939
$baseDir = $app['config']['typesetsh.base_dir'] ?? [];
4040
$allowProtocols = $app['config']['typesetsh.allowed_protocols'] ?? [];
4141
$cacheDir = $app['config']['typesetsh.cache_dir'] ?? null;
42-
$timeout = (int)($app['config']['typesetsh.timeout'] ?? 15);
43-
$downloadLimit = (int)($app['config']['typesetsh.download_limit'] ?? 1024 * 1024 * 5);
44-
$pdfVersion = (string)($app['config']['typesetsh.pdf_version'] ?? '1.6');
42+
$timeout = (int) ($app['config']['typesetsh.timeout'] ?? 15);
43+
$downloadLimit = (int) ($app['config']['typesetsh.download_limit'] ?? 1024 * 1024 * 5);
44+
$pdfVersion = (string) ($app['config']['typesetsh.pdf_version'] ?? '1.6');
4545

4646
$schemes = [];
4747
$schemes['data'] = new UriResolver\Data($cacheDir);

src/Typesetsh.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ public function render(string $html): Result
3737
$result = $this->html2pdf->render($html, $this->uriResolver);
3838
$result->version = $this->version;
3939

40+
// Append any issues from URI resolver to result
41+
if ($this->uriResolver instanceof UriResolver && $this->uriResolver->errors) {
42+
array_push($result->issues, ...$this->uriResolver->errors);
43+
$this->uriResolver->errors = [];
44+
}
45+
4046
return $result;
4147
}
4248

@@ -48,6 +54,12 @@ public function renderMultiple(array $html): Result
4854
$result = $this->html2pdf->renderMultiple($html, $this->uriResolver);
4955
$result->version = $this->version;
5056

57+
// Append any issues from URI resolver to result
58+
if ($this->uriResolver instanceof UriResolver && $this->uriResolver->errors) {
59+
array_push($result->issues, ...$this->uriResolver->errors);
60+
$this->uriResolver->errors = [];
61+
}
62+
5163
return $result;
5264
}
5365
}

0 commit comments

Comments
 (0)