Skip to content

Commit c166b99

Browse files
committed
Support typeset.sh v0.16
1 parent 0f15e03 commit c166b99

File tree

9 files changed

+31
-24
lines changed

9 files changed

+31
-24
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Alternative you can use the helper.
4848
Route::get('/invoice/print', function () {
4949
$invoice = new stdClass();
5050

51-
return typesetsh\pdf('invoice', ['invoice' => $invoice]);
51+
return Typesetsh\pdf('invoice', ['invoice' => $invoice]);
5252
});
5353
```
5454

@@ -59,7 +59,7 @@ or force a download
5959
Route::get('/invoice/print', function () {
6060
$invoice = new stdClass();
6161

62-
return typesetsh\pdf('invoice', ['invoice' => $invoice])->forceDownload('invoice.pdf');
62+
return Typesetsh\pdf('invoice', ['invoice' => $invoice])->forceDownload('invoice.pdf');
6363
});
6464
```
6565

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"minimum-stability": "stable",
1717
"require": {
1818
"laravel/framework": "^7.0 || ^8.0",
19-
"typesetsh/typesetsh": "^0.15"
19+
"typesetsh/typesetsh": "^0.16"
2020
},
2121
"require-dev": {
2222
"friendsofphp/php-cs-fixer": "^2.16"

config/typesetsh.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@
5151
*/
5252

5353
'timeout' => 15,
54+
55+
/*
56+
|--------------------------------------------------------------------------
57+
| Download Limit
58+
|--------------------------------------------------------------------------
59+
|
60+
| Max file-size when downloading remote resources. Only works when ext-curl
61+
| is available.
62+
|
63+
*/
64+
65+
'download_limit' => 1024 * 1024 * 5,
5466
];

src/Facades/Pdf.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright (c) 2020 Jacob Siefer
44
* See LICENSE bundled with this package for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Typesetsh\LaravelWrapper\Facades;

src/Pdf/Factory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright (c) 2020 Jacob Siefer
44
* See LICENSE bundled with this package for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Typesetsh\LaravelWrapper\Pdf;

src/Pdf/View.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright (c) 2020 Jacob Siefer
44
* See LICENSE bundled with this package for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Typesetsh\LaravelWrapper\Pdf;

src/ServiceProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
* Copyright (c) 2020 Jacob Siefer
44
* See LICENSE bundled with this package for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Typesetsh\LaravelWrapper;
109

11-
use Illuminate\Contracts\Support\DeferrableProvider;
10+
use Illuminate\Contracts;
1211
use Illuminate\Support;
13-
use typesetsh\UriResolver;
12+
use Typesetsh\UriResolver;
1413

15-
class ServiceProvider extends Support\ServiceProvider implements DeferrableProvider
14+
class ServiceProvider extends Support\ServiceProvider implements Contracts\Support\DeferrableProvider
1615
{
1716
const CONFIG_PATH = __DIR__.'/../config/typesetsh.php';
1817

@@ -39,11 +38,14 @@ protected function registerPdfRenderer(): void
3938
$allowedDirectories = $app['config']['typesetsh.allowed_directories'] ?? [];
4039
$allowProtocols = $app['config']['typesetsh.allowed_protocols'] ?? [];
4140
$cacheDir = $app['config']['typesetsh.cache_dir'] ?? null;
42-
$timeout = $app['config']['typesetsh.timeout'] ?? 15;
41+
$timeout = (int)($app['config']['typesetsh.timeout'] ?? 15);
42+
$downloadLimit = (int)($app['config']['typesetsh.download_limit'] ?? 1024 * 1024 * 5);
4343

4444
$schemes = [];
45+
$schemes['data'] = new UriResolver\Data($cacheDir);
46+
4547
if ($allowProtocols) {
46-
$http = new UriResolver\Http($cacheDir, $timeout);
48+
$http = new UriResolver\Http($cacheDir, $timeout, $downloadLimit);
4749
foreach ($allowProtocols as $protocol) {
4850
$schemes[$protocol] = $http;
4951
}

src/Typesetsh.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,23 @@
33
* Copyright (c) 2020 Jacob Siefer
44
* See LICENSE bundled with this package for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Typesetsh\LaravelWrapper;
109

11-
use typesetsh\HtmlToPdf;
12-
use typesetsh\Result;
13-
use typesetsh\UriResolver;
10+
use Typesetsh\HtmlToPdf;
11+
use Typesetsh\Result;
12+
use Typesetsh\UriResolver;
1413

1514
/**
1615
* Typeset.sh pdf wrapper with a pre provided uri resolver.
1716
*/
1817
class Typesetsh
1918
{
20-
/**
21-
* @var HtmlToPdf
22-
*/
19+
/** @var HtmlToPdf */
2320
private $html2pdf;
2421

25-
/**
26-
* @var callable|UriResolver
27-
*/
22+
/** @var callable|UriResolver */
2823
private $uriResolver;
2924

3025
public function __construct(callable $uriResolver = null, HtmlToPdf $html2pdf = null)
@@ -39,7 +34,7 @@ public function render(string $html): Result
3934
}
4035

4136
/**
42-
* @param string[] $html
37+
* @param non-empty-list<string> $html
4338
*/
4439
public function renderMultiple(array $html): Result
4540
{

src/helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* Copyright (c) 2020 Jacob Siefer
44
* See LICENSE bundled with this package for license details.
55
*/
6+
declare(strict_types=1);
67

7-
namespace typesetsh;
8+
namespace Typesetsh;
89

910
use Typesetsh\LaravelWrapper\Pdf;
1011

0 commit comments

Comments
 (0)