Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Made it Compatible with Lumen #148

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "niklasravnsborg/laravel-pdf",
"name": "kiasaty/lumen-pdf",
"description": "Generate PDFs in Laravel with this mPDF wrapper.",
"keywords": ["mpdf", "pdf", "laravel"],
"homepage": "https://github.com/kiasaty/lumen-pdf",
"license": "MIT",
"scripts": {
"test": "phpunit --colors=always"
Expand Down
9 changes: 4 additions & 5 deletions src/LaravelPdf/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace niklasravnsborg\LaravelPdf;

use Config;
use Mpdf;

/**
Expand Down Expand Up @@ -62,13 +61,13 @@ protected function getConfig($key)
if (isset($this->config[$key])) {
return $this->config[$key];
} else {
return Config::get('pdf.' . $key);
return config('pdf.' . $key);
}
}

protected function addCustomFontsConfig($mpdf_config)
{
if (!Config::has('pdf.font_path') || !Config::has('pdf.font_data')) {
if (!config()->has('pdf.font_path') || !config()->has('pdf.font_data')) {
return $mpdf_config;
}

Expand All @@ -77,8 +76,8 @@ protected function addCustomFontsConfig($mpdf_config)
$fontData = (new Mpdf\Config\FontVariables())->getDefaults()['fontdata'];

// Merge default with custom configuration
$mpdf_config['fontDir'] = array_merge($fontDirs, [Config::get('pdf.font_path')]);
$mpdf_config['fontdata'] = array_merge($fontData, Config::get('pdf.font_data'));
$mpdf_config['fontDir'] = array_merge($fontDirs, [config('pdf.font_path')]);
$mpdf_config['fontdata'] = array_merge($fontData, config('pdf.font_data'));

return $mpdf_config;
}
Expand Down
5 changes: 2 additions & 3 deletions src/LaravelPdf/PdfServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace niklasravnsborg\LaravelPdf;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class PdfServiceProvider extends BaseServiceProvider {
Expand All @@ -23,7 +22,7 @@ class PdfServiceProvider extends BaseServiceProvider {
public function boot()
{
$this->publishes([
__DIR__ . '/../config/pdf.php' => config_path('pdf.php'),
__DIR__ . '/../config/pdf.php' => app()->basePath('config/pdf.php'),
]);
}

Expand All @@ -38,7 +37,7 @@ public function register()
__DIR__ . '/../config/pdf.php', 'pdf'
);

$this->app->bind('mpdf.wrapper', function($app) {
app()->bind('mpdf.wrapper', function($app) {
return new PdfWrapper();
});
}
Expand Down
5 changes: 2 additions & 3 deletions src/LaravelPdf/PdfWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace niklasravnsborg\LaravelPdf;

use File;
use View;

class PdfWrapper {

Expand All @@ -26,7 +25,7 @@ public function loadHTML($html, $config = [])
*/
public function loadFile($file, $config = [])
{
return new Pdf(File::get($file), $config);
return new Pdf(file($file), $config);
}

/**
Expand All @@ -39,7 +38,7 @@ public function loadFile($file, $config = [])
*/
public function loadView($view, $data = [], $mergeData = [], $config = [])
{
return new Pdf(View::make($view, $data, $mergeData)->render(), $config);
return new Pdf(view($view, $data, $mergeData)->render(), $config);
}

}
5 changes: 2 additions & 3 deletions src/mpdf_ttfonts_config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

use Illuminate\Support\Facades\Config;
define('_MPDF_SYSTEM_TTFONTS', Config::get('pdf.custom_font_path'));
$this->fontdata = array_merge($this->fontdata, Config::get('pdf.custom_font_data'));
define('_MPDF_SYSTEM_TTFONTS', config('pdf.custom_font_path'));
$this->fontdata = array_merge($this->fontdata, config('pdf.custom_font_data'));