Skip to content

Commit e097e9c

Browse files
committed
Initial commit.
0 parents  commit e097e9c

File tree

8 files changed

+154
-0
lines changed

8 files changed

+154
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
composer.lock
3+
vendor

.travis.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- 7.0
8+
- hhvm
9+
10+
sudo: false
11+
12+
env:
13+
- COMPOSER_OPTS=""
14+
- COMPOSER_OPTS="--prefer-lowest"
15+
16+
before_script:
17+
- travis_retry composer self-update
18+
- travis_retry composer update $COMPOSER_OPTS
19+
20+
script:
21+
- php vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
22+
23+
after_script:
24+
- wget https://scrutinizer-ci.com/ocular.phar
25+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Jonathan Reinink <[email protected]>
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
13+
all 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
21+
THE SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Glide adapter for CakePHP
2+
3+
[![Author](http://img.shields.io/badge/[email protected]?style=flat-square)](https://twitter.com/reinink)
4+
[![Latest Version](https://img.shields.io/github/release/thephpleague/glide-cake.svg?style=flat-square)](https://github.com/thephpleague/glide-cake/releases)
5+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/thephpleague/glide-cake/blob/master/LICENSE)
6+
[![Build Status](https://img.shields.io/travis/thephpleague/glide-cake/master.svg?style=flat-square)](https://travis-ci.org/thephpleague/glide-cake)
7+
[![HHVM Status](https://img.shields.io/hhvm/league/glide-cake.svg?style=flat-square)](http://hhvm.h4cc.de/package/league/glide-cake)
8+
[![Total Downloads](https://img.shields.io/packagist/dt/league/glide-cake.svg?style=flat-square)](https://packagist.org/packages/league/glide-cake)
9+
10+
## Installation
11+
12+
```bash
13+
$ composer require league/glide-cake
14+
```
15+
16+
## Documentation
17+
18+
Full documentation can be found at [glide.thephpleague.com](http://glide.thephpleague.com).

composer.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "league/glide-cake",
3+
"description": "Glide adapter for CakePHP",
4+
"homepage": "http://glide.thephpleague.com",
5+
"license": "MIT",
6+
"authors" : [
7+
{
8+
"name": "Jonathan Reinink",
9+
"email": "[email protected]",
10+
"homepage": "http://reinink.ca"
11+
}
12+
],
13+
"require": {
14+
"cakephp/cakephp": "~3.0",
15+
"league/flysystem": "^1.0",
16+
"league/glide": "dev-master",
17+
"php": ">=5.4"
18+
},
19+
"require-dev": {
20+
"mockery/mockery": "^0.9",
21+
"phpunit/phpunit": "^4.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"League\\Glide\\": "src/"
26+
}
27+
}
28+
}

phpunit.xml.dist

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit colors="true" bootstrap="vendor/autoload.php">
3+
<testsuites>
4+
<testsuite name="all">
5+
<directory suffix="Test.php">tests/</directory>
6+
</testsuite>
7+
</testsuites>
8+
<filter>
9+
<whitelist>
10+
<directory suffix=".php">src/</directory>
11+
</whitelist>
12+
</filter>
13+
<logging>
14+
<log type="tap" target="build/report.tap"/>
15+
<log type="junit" target="build/report.junit.xml"/>
16+
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
17+
<log type="coverage-text" target="build/coverage.txt"/>
18+
<log type="coverage-clover" target="build/logs/clover.xml"/>
19+
</logging>
20+
</phpunit>

src/Responses/CakeResponseFactory.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace League\Glide\Responses;
4+
5+
use Cake\Network\Response;
6+
use League\Flysystem\FilesystemInterface;
7+
8+
class CakeResponseFactory implements ResponseFactoryInterface
9+
{
10+
/**
11+
* Create the response.
12+
* @param FilesystemInterface $cache The cache file system.
13+
* @param string $path The cached file path.
14+
* @return Response The response object.
15+
*/
16+
public function create(FilesystemInterface $cache, $path)
17+
{
18+
$stream = $cache->readStream($path);
19+
20+
$contentType = $cache->getMimetype($path);
21+
$contentLength = (string) $cache->getSize($path);
22+
$cacheControl = 'max-age=31536000, public';
23+
$expires = date_create('+1 years')->format('D, d M Y H:i:s').' GMT';
24+
25+
$response = new Response();
26+
$response->type($contentType);
27+
$response->header('Content-Length', $contentLength);
28+
$response->header('Cache-Control', $cacheControl);
29+
$response->header('Expires', $expires);
30+
$response->body(function () use ($stream) {
31+
rewind($stream);
32+
fpassthru($stream);
33+
fclose($stream);
34+
});
35+
36+
return $response;
37+
}
38+
}

0 commit comments

Comments
 (0)