-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from reyostallenberg/events
Dispatch events in DompdfWrapper
- Loading branch information
Showing
11 changed files
with
279 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\DompdfBundle; | ||
|
||
final class DompdfEvents | ||
{ | ||
const OUTPUT = 'dompdf.output'; | ||
const STREAM = 'dompdf.stream'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\DompdfBundle\Event; | ||
|
||
use Dompdf\Dompdf; | ||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
final class OutputEvent extends Event | ||
{ | ||
/** | ||
* @var Dompdf | ||
*/ | ||
private $pdf; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $html; | ||
|
||
/** | ||
* @param Dompdf $pdf | ||
* @param string $html | ||
*/ | ||
public function __construct(Dompdf $pdf, string $html) | ||
{ | ||
$this->pdf = $pdf; | ||
$this->html = $html; | ||
} | ||
|
||
/** | ||
* Returns the dompdf instance. | ||
* | ||
* @return Dompdf | ||
*/ | ||
public function getPdf(): Dompdf | ||
{ | ||
return $this->pdf; | ||
} | ||
|
||
/** | ||
* Returns the html. | ||
* | ||
* @return string | ||
*/ | ||
public function getHtml(): string | ||
{ | ||
return $this->html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\DompdfBundle\Event; | ||
|
||
use Dompdf\Dompdf; | ||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
final class StreamEvent extends Event | ||
{ | ||
/** | ||
* @var Dompdf | ||
*/ | ||
private $pdf; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $filename; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $html; | ||
|
||
/** | ||
* @param Dompdf $pdf | ||
* @param string $filename | ||
* @param string $html | ||
*/ | ||
public function __construct(Dompdf $pdf, string $filename, string $html) | ||
{ | ||
$this->pdf = $pdf; | ||
$this->filename = $filename; | ||
$this->html = $html; | ||
} | ||
|
||
/** | ||
* Returns the dompdf instance. | ||
* | ||
* @return Dompdf | ||
*/ | ||
public function getPdf(): Dompdf | ||
{ | ||
return $this->pdf; | ||
} | ||
|
||
/** | ||
* Returns the filename. | ||
* | ||
* @return string | ||
*/ | ||
public function getFilename(): string | ||
{ | ||
return $this->filename; | ||
} | ||
|
||
/** | ||
* Returns the html. | ||
* | ||
* @return string | ||
*/ | ||
public function getHtml(): string | ||
{ | ||
return $this->html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\DompdfBundle\Tests\Event; | ||
|
||
use Core23\DompdfBundle\Event\OutputEvent; | ||
use Dompdf\Dompdf; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class OutputEventTest extends TestCase | ||
{ | ||
public function testEvent(): void | ||
{ | ||
$dompdf = $this->createMock(Dompdf::class); | ||
$html = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>"; | ||
|
||
$event = new OutputEvent($dompdf, $html); | ||
|
||
$this->assertInstanceOf(Dompdf::class, $event->getPdf()); | ||
$this->assertSame($dompdf, $event->getPdf()); | ||
$this->assertSame($html, $event->getHtml()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* (c) Christian Gripp <mail@core23.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Core23\DompdfBundle\Tests\Event; | ||
|
||
use Core23\DompdfBundle\Event\StreamEvent; | ||
use Dompdf\Dompdf; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class StreamEventTest extends TestCase | ||
{ | ||
public function testEvent(): void | ||
{ | ||
$dompdf = $this->createMock(Dompdf::class); | ||
$filename = 'file.pdf'; | ||
$html = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>"; | ||
|
||
$event = new StreamEvent($dompdf, $filename, $html); | ||
|
||
$this->assertInstanceOf(Dompdf::class, $event->getPdf()); | ||
$this->assertSame($dompdf, $event->getPdf()); | ||
$this->assertSame($filename, $event->getFilename()); | ||
$this->assertSame($html, $event->getHtml()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters