Skip to content

Commit b7b9aa9

Browse files
committed
WIP adjust to 2.0 and new setup with PSR7
1 parent ffd6b9f commit b7b9aa9

File tree

12 files changed

+72
-27
lines changed

12 files changed

+72
-27
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 5.3
54
- 5.4
65
- 5.5
76
- 7.0
@@ -36,11 +35,17 @@ matrix:
3635
env:
3736
- SYMFONY_VERSION='2.7.*@dev'
3837
- FRAMEWORK_EXTRA_VERSION='~3.0'
38+
- php: 5.4
39+
env:
40+
- SYMFONY_VERSION=2.3.*
41+
- COMPOSER_FLAGS="--prefer-lowest"
3942

4043
before_script:
4144
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
4245
- sh -c 'if [ "$FRAMEWORK_EXTRA_VERSION" != "" ]; then composer require --dev --no-update sensio/framework-extra-bundle=$FRAMEWORK_EXTRA_VERSION; fi;'
43-
- composer install
46+
- if [[ "$TRAVIS_PHP_VERSION" == "5.4" || "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then composer remove "php-http/guzzle6-adapter" --dev --no-update; fi
47+
- if [[ "$TRAVIS_PHP_VERSION" == "5.4" || "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then composer require "php-http/guzzle5-adapter" --dev --no-update; fi
48+
- composer update $COMPOSER_FLAGS --no-interaction
4449
- sudo apt-get install python-sphinx enchant
4550
- sudo pip install -r Resources/doc/requirements.txt
4651

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
=========
33

4+
2.0.0 (unreleased)
5+
------------------
6+
7+
* Updated the version of FOSHttpCache to 2.*. See [FOSHttpCache changelog]
8+
(https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/CHANGELOG.md).
9+
Most important, there is no more hard coupling on Guzzle HTTP client. We now
10+
use the HTTP adapter. You now need to explicitly specify the adapter you
11+
want, see [installation instructions]
12+
(http://foshttpcachebundle.readthedocs.org/en/stable/installation.html)
13+
414
1.3.2
515
-----
616

DependencyInjection/Compiler/LoggerPass.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
namespace FOS\HttpCacheBundle\DependencyInjection\Compiler;
1313

14+
use FOS\HttpCache\Events;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617

1718
/**
18-
* Attach Symfony2 logger to cache manager
19+
* Announce the log listener to the symfony event system
1920
*/
2021
class LoggerPass implements CompilerPassInterface
2122
{
@@ -28,10 +29,9 @@ public function process(ContainerBuilder $container)
2829
return;
2930
}
3031

31-
$subscriber = $container->getDefinition('fos_http_cache.event_listener.log')
32-
->setAbstract(false);
33-
34-
$container->getDefinition('fos_http_cache.cache_manager')
35-
->addMethodCall('addSubscriber', array($subscriber));
32+
$container->getDefinition('fos_http_cache.event_listener.log')
33+
->setAbstract(false)
34+
->addTag('kernel.event_subscriber');
35+
;
3636
}
3737
}

DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,6 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo
315315
if (!empty($config['rules'])) {
316316
$this->loadTagRules($container, $config['rules']);
317317
}
318-
319-
$tagsHeader = $config['header'];
320-
$container->getDefinition($this->getAlias().'.cache_manager')
321-
->addMethodCall('setTagsHeader', array($tagsHeader))
322-
;
323318
}
324319

325320
private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, array $config)

Resources/config/matcher.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
<service id="fos_http_cache.request_matcher"
1414
class="%fos_http_cache.request_matcher.class%"
1515
public="false"
16+
abstract="true"
1617
/>
17-
18+
1819
<service id="fos_http_cache.rule_matcher"
1920
class="%fos_http_cache.rule_matcher.class%"
2021
public="false"
22+
abstract="true"
2123
>
2224
<argument/>
2325
<argument/>

Resources/config/nginx.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
<argument>%fos_http_cache.proxy_client.nginx.purge_location%</argument>
1717
<argument type="service" id="fos_http_cache.proxy_client.nginx.guzzle_client" on-invalid="ignore"/>
1818
</service>
19-
19+
<!--
2020
<service id="fos_http_cache.test.client.nginx"
2121
parent="fos_http_cache.test.client.abstract"
2222
abstract="true">
2323
<argument index="0">%fos_http_cache.proxy_client.nginx.base_url%</argument>
2424
</service>
25+
-->
2526
</services>
2627

2728
</container>

Resources/config/test_client.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
<parameter key="fos_http_cache.test.client.curlopt_forbid_reuse" type="constant">CURLOPT_FORBID_REUSE</parameter>
1010
</parameters>
1111

12-
<services>
13-
<service id="fos_http_cache.test.client.abstract"
14-
class="%fos_http_cache.test.client.class%"
15-
abstract="true">
16-
<argument /><!-- base_url -->
12+
<!--
13+
TODO: how to handle guzzle in future?
14+
<services>
15+
<service id="fos_http_cache.test.client.abstract"
16+
class="%fos_http_cache.test.client.class%"
17+
abstract="true">
18+
<argument />--><!-- base_url --><!--
1719
<argument type="collection">
1820
<argument key="%fos_http_cache.test.client.curlopt_forbid_reuse%">true</argument>
1921
</argument>
2022
</service>
2123
</services>
24+
-->
2225

2326
</container>

Resources/config/varnish.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
<argument>%fos_http_cache.proxy_client.varnish.base_url%</argument>
1616
<argument type="service" id="fos_http_cache.proxy_client.varnish.guzzle_client" on-invalid="ignore"/>
1717
</service>
18-
18+
<!--
1919
<service id="fos_http_cache.test.client.varnish"
2020
parent="fos_http_cache.test.client.abstract"
2121
abstract="true">
2222
<argument index="0">%fos_http_cache.proxy_client.varnish.base_url%</argument>
2323
</service>
24-
24+
-->
2525
</services>
2626

2727
</container>

Resources/doc/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
FOSHttpCacheBundle
22
==================
33

4+
.. note::
5+
6+
This documentation is for the (upcoming) 2.0 of the library. For the stable
7+
1.* version, please refer to the `stable documentation`_.
8+
49
This is the documentation for the `FOSHttpCacheBundle <https://github.com/FriendsOfSymfony/FOSHttpCacheBundle>`_.
510
Use the FOSHttpCacheBundle to:
611

@@ -23,3 +28,5 @@ Contents
2328

2429
testing
2530
contributing
31+
32+
.. _stable documentation: http://foshttpcachebundle.readthedocs.org/en/stable/

Resources/doc/overview.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ This bundle is available on Packagist_. You can install it using Composer:
88

99
.. code-block:: bash
1010
11-
$ composer require friendsofsymfony/http-cache-bundle:~1.0
11+
$ composer require friendsofsymfony/http-cache-bundle
12+
13+
Note that the FOSHttpCache_ library needs a ``psr/http-message-implementation``
14+
and ``php-http/adapter-implementation``. If your project does not contain one,
15+
composer will complain that it did not find ``psr/http-message-implementation``.
16+
17+
When on PHP 5.5+, use the following line instead:
18+
19+
.. code-block:: bash
20+
21+
$ composer require friendsofsymfony/http-cache-bundle:~2.0 guzzlehttp/psr7:^1.0 php-http/guzzle6-adapter:^0.1.0
22+
23+
On PHP 5.4, the ``php-http/guzzle5-adapter:^0.1.0`` works fine.
1224

1325
Then add the bundle to your application:
1426

Test/ProxyTestCase.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use FOS\HttpCache\Test\Proxy\ProxyInterface;
88
use Guzzle\Http\ClientInterface;
99
use Guzzle\Http\Message\Response;
10+
use Http\Adapter\HttpAdapter;
11+
use Http\Discovery\MessageFactoryDiscovery;
1012
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1113
use Symfony\Component\DependencyInjection\ContainerInterface;
1214

@@ -62,7 +64,7 @@ public static function isCacheMiss()
6264
* Get HTTP test client for making requests to your application through a
6365
* live caching proxy
6466
*
65-
* @return ClientInterface
67+
* @return HttpAdapter
6668
*/
6769
protected function getHttpClient()
6870
{
@@ -72,15 +74,22 @@ protected function getHttpClient()
7274
/**
7375
* Get a response from your application through a live caching proxy
7476
*
75-
* @param string $url Request URL (absolute or relative)
77+
* @param string $uri Request URL (absolute or relative)
7678
* @param array $headers Request HTTP headers
7779
* @param array $options Request options
7880
*
7981
* @return Response
8082
*/
81-
protected function getResponse($url, array $headers = array(), $options = array())
83+
protected function getResponse($uri, array $headers = array())
8284
{
83-
return $this->getHttpClient()->get($url, $headers, $options)->send();
85+
$request = MessageFactoryDiscovery::find()->createRequest(
86+
'GET',
87+
$uri,
88+
'1.1',
89+
$headers
90+
);
91+
92+
return $this->getHttpClient()->sendRequest($request);
8493
}
8594

8695
/**

Tests/Unit/CacheManagerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function testRefreshRoute()
8282

8383
public function testTagResponse()
8484
{
85+
$this->markTestSkipped('TODO refactor to use tag handler');
8586
$ban = \Mockery::mock('\FOS\HttpCache\ProxyClient\Invalidation\BanInterface');
8687
$router = \Mockery::mock('\Symfony\Component\Routing\Generator\UrlGeneratorInterface');
8788

0 commit comments

Comments
 (0)