resolved conflicts

This commit is contained in:
2025-03-31 03:46:05 +03:00
6454 changed files with 1520539 additions and 9 deletions
@@ -0,0 +1,57 @@
{
"name": "barryvdh/laravel-snappy",
"description": "Snappy PDF/Image for Laravel",
"keywords": [
"laravel",
"snappy",
"pdf",
"image",
"wkhtmltopdf",
"wkhtmltoimage"
],
"license": "MIT",
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"require": {
"php": ">=7.2",
"illuminate/support": "^9|^10|^11.0",
"illuminate/filesystem": "^9|^10|^11.0",
"knplabs/knp-snappy": "^1.4.4"
},
"require-dev": {
"orchestra/testbench": "^7|^8|^9.0"
},
"autoload": {
"psr-4": {
"Barryvdh\\Snappy\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Barryvdh\\Snappy\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Barryvdh\\Snappy\\ServiceProvider"
],
"aliases": {
"PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf",
"SnappyImage": "Barryvdh\\Snappy\\Facades\\SnappyImage"
}
}
},
"scripts": {
"test": "phpunit"
},
"minimum-stability": "dev",
"prefer-stable": true
}
@@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Snappy PDF / Image Configuration
|--------------------------------------------------------------------------
|
| This option contains settings for PDF generation.
|
| Enabled:
|
| Whether to load PDF / Image generation.
|
| Binary:
|
| The file path of the wkhtmltopdf / wkhtmltoimage executable.
|
| Timeout:
|
| The amount of time to wait (in seconds) before PDF / Image generation is stopped.
| Setting this to false disables the timeout (unlimited processing time).
|
| Options:
|
| The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
| See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
|
| Env:
|
| The environment variables to set while running the wkhtmltopdf process.
|
*/
'pdf' => [
'enabled' => true,
'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
'timeout' => false,
'options' => [],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'),
'timeout' => false,
'options' => [],
'env' => [],
],
];
@@ -0,0 +1,108 @@
<?php namespace Barryvdh\Snappy;
use Knp\Snappy\Image;
use Illuminate\Filesystem\Filesystem;
class IlluminateSnappyImage extends Image {
/**
* @var \Illuminate\Filesystem\Filesystem
*/
protected $fs;
/**
* @param \Illuminate\Filesystem\Filesystem
* @param string $binary
* @param array $options
*/
public function __construct(Filesystem $fs, $binary, array $options, array $env)
{
parent::__construct($binary, $options, $env);
$this->fs = $fs;
}
/**
* Wrapper for the "file_get_contents" function
*
* @param string $filename
*
* @return string
*/
protected function getFileContents($filename)
{
return $this->fs->get($filename);
}
/**
* Wrapper for the "file_exists" function
*
* @param string $filename
*
* @return boolean
*/
protected function fileExists($filename)
{
return $this->fs->exists($filename);
}
/**
* Wrapper for the "is_file" method
*
* @param string $filename
*
* @return boolean
*/
protected function isFile($filename)
{
return $this->fs->isFile($filename);
}
/**
* Wrapper for the "filesize" function
*
* @param string $filename
*
* @return integer or FALSE on failure
*/
protected function filesize($filename)
{
return $this->fs->size($filename);
}
/**
* Wrapper for the "unlink" function
*
* @param string $filename
*
* @return boolean
*/
protected function unlink($filename)
{
return $this->fs->delete($filename);
}
/**
* Wrapper for the "is_dir" function
*
* @param string $filename
*
* @return boolean
*/
protected function isDir($filename)
{
return $this->fs->isDirectory($filename);
}
/**
* Wrapper for the mkdir function
*
* @param string $pathname
*
* @return boolean
*/
protected function mkdir($pathname)
{
return $this->fs->makeDirectory($pathname, 0777, true, true);
}
}
@@ -0,0 +1,208 @@
<?php namespace Barryvdh\Snappy;
use Illuminate\Http\Response;
use Knp\Snappy\Image as SnappyImage;
use Illuminate\Support\Facades\View;
use Symfony\Component\HttpFoundation\StreamedResponse;
/**
* A Laravel wrapper for SnappyImage
*
* @package laravel-snappy
* @author Killian Blais
*/
class ImageWrapper {
/**
* @var \Knp\Snappy\Image
*/
protected $snappy;
/**
* @var array
*/
protected $options = array();
/**
* @var string
*/
protected $html;
/**
* @var string
*/
protected $file;
/**
* @param \Knp\Snappy\Image $snappy
*/
public function __construct(SnappyImage $snappy)
{
$this->snappy = $snappy;
}
/**
* Get the Snappy instance.
*
* @return \Knp\Snappy\Image
*/
public function snappy()
{
return $this->snappy;
}
public function setOption($name, $value)
{
$this->snappy->setOption($name, $value);
return $this;
}
public function setOptions($options)
{
$this->snappy->setOptions($options);
return $this;
}
/**
* Load a HTML string
*
* @param string $string
* @return static
*/
public function loadHTML($string)
{
$this->html = (string) $string;
$this->file = null;
return $this;
}
/**
* Load a HTML file
*
* @param string $file
* @return static
*/
public function loadFile($file)
{
$this->html = null;
$this->file = $file;
return $this;
}
public function loadView($view, $data = array(), $mergeData = array())
{
$this->html = View::make($view, $data, $mergeData)->render();
$this->file = null;
return $this;
}
/**
* Output the PDF as a string.
*
* @return string The rendered PDF as string
* @throws \InvalidArgumentException
*/
public function output()
{
if ($this->html)
{
return $this->snappy->getOutputFromHtml($this->html, $this->options);
}
if ($this->file)
{
return $this->snappy->getOutput($this->file, $this->options);
}
throw new \InvalidArgumentException('Image Generator requires a html or file in order to produce output.');
}
/**
* Save the image to a file
*
* @param $filename
* @return static
*/
public function save($filename, $overwrite = false)
{
if ($this->html)
{
$this->snappy->generateFromHtml($this->html, $filename, $this->options, $overwrite);
}
elseif ($this->file)
{
$this->snappy->generate($this->file, $filename, $this->options, $overwrite);
}
return $this;
}
/**
* Make the image downloadable by the user
*
* @param string $filename
* @return \Symfony\Component\HttpFoundation\Response
*/
public function download($filename = 'image.jpg')
{
return new Response($this->output(), 200, array(
'Content-Type' => 'image/jpeg',
'Content-Disposition' => 'attachment; filename="'.$filename.'"'
));
}
/**
* Return a response with the image to show in the browser
*
* @param string $filename
* @return \Illuminate\Http\Response
*/
public function inline($filename = 'image.jpg')
{
return new Response($this->output(), 200, array(
'Content-Type' => 'image/jpeg',
'Content-Disposition' => 'inline; filename="'.$filename.'"',
));
}
/**
* Return a response with the image to show in the browser
*
* @deprecated Use inline() instead
* @param string $filename
* @return \Symfony\Component\HttpFoundation\Response
*/
public function stream($filename = 'image.jpg')
{
return new StreamedResponse(function() {
echo $this->output();
}, 200, array(
'Content-Type' => 'image/jpeg',
'Content-Disposition' => 'inline; filename="'.$filename.'"',
));
}
/**
* Call Snappy instance.
*
* Also shortcut's
* ->html => loadHtml
* ->view => loadView
* ->file => loadFile
*
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, array $arguments)
{
$method = 'load' . ucfirst($name);
if (method_exists($this, $method))
{
return call_user_func_array(array($this, $method), $arguments);
}
return call_user_func_array (array($this->snappy, $name), $arguments);
}
}