Source of file File.php
Size: 1,179 Bytes - Last Modified: 2021-12-24T06:51:27+00:00
/var/www/docs.ssmods.com/process/src/src/Output/File.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | <?php namespace Heyday\SilverStripe\WkHtml\Output; use Knp\Snappy\GeneratorInterface; use SilverStripe\Core\Injector\Injectable; /** * Class File * @package Heyday\SilverStripe\WkHtml\Output */ class File implements OutputInterface { use Injectable; /** * @var bool */ protected $overwrite = false; /** * @var bool */ protected $path = false; /** * @param $path * @param bool $overwrite */ public function __construct($path, $overwrite = false) { if (file_exists($path) && !$overwrite) { throw new \RuntimeException('File already exists.'); } elseif (!is_writable(dirname($path))) { throw new \RuntimeException('Directory is not writable.'); } else { $this->path = $path; } $this->overwrite = $overwrite; } /** * @param $input * @param GeneratorInterface $generator * @return bool */ public function process($input, GeneratorInterface $generator) { $generator->generateFromHtml($input, $this->path, [], $this->overwrite); return $this->path; } } |