Skip to content

Commit 59ef8f2

Browse files
Initial commit
0 parents  commit 59ef8f2

File tree

6 files changed

+101
-0
lines changed

6 files changed

+101
-0
lines changed

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Dmitri Vereshchagin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# yii-snappy
2+
Basic wrapper around [Snappy](https://github.com/KnpLabs/snappy) implemented as Yii component

composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "dmitrivereshchagin/yii-snappy",
3+
"description": "Basic wrapper around Snappy implemented as Yii component",
4+
"license": "MIT",
5+
"require": {
6+
"php": ">=5.3.0",
7+
"knplabs/knp-snappy": "0.4.*"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"Snappy\\": "src/"
12+
}
13+
}
14+
}

src/AbstractComponent.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Snappy;
4+
5+
abstract class AbstractComponent extends \CApplicationComponent
6+
{
7+
/**
8+
* @var string
9+
*/
10+
public $binary;
11+
/**
12+
* @var array
13+
*/
14+
public $options = array();
15+
16+
/**
17+
* @return \Knp\Snappy\GeneratorInterface
18+
*/
19+
abstract protected function getGenerator();
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function __call($name, $parameters)
25+
{
26+
if (method_exists('\Knp\Snappy\GeneratorInterface', $name)) {
27+
return call_user_func_array(
28+
array($this->getGenerator(), $name),
29+
$parameters
30+
);
31+
}
32+
33+
return parent::__call($name, $parameters);
34+
}
35+
}

src/ImageComponent.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Snappy;
4+
5+
class ImageComponent extends AbstractComponent
6+
{
7+
/**
8+
* {@inheritdoc}
9+
*/
10+
protected function getGenerator()
11+
{
12+
return new \Knp\Snappy\Image($this->binary, $this->options);
13+
}
14+
}

src/PdfComponent.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Snappy;
4+
5+
class PdfComponent extends AbstractComponent
6+
{
7+
/**
8+
* {@inheritdoc}
9+
*/
10+
protected function getGenerator()
11+
{
12+
return new \Knp\Snappy\Pdf($this->binary, $this->options);
13+
}
14+
}

0 commit comments

Comments
 (0)