Skip to content

Commit 0c8c4fd

Browse files
committed
WIP adjust to 2.0 and new setup with PSR7
1 parent 3b3202e commit 0c8c4fd

File tree

10 files changed

+57
-22
lines changed

10 files changed

+57
-22
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Changelog
1010

1111
* [Event Listeners] Renamed the event listener classes to XxxLlistener
1212

13+
* Updated the version of FOSHttpCache to 2.*. See [FOSHttpCache changelog]
14+
(https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/CHANGELOG.md).
15+
Most important, there is no more hard coupling on Guzzle HTTP client. We now
16+
use the HTTP adapter. You now need to explicitly specify the adapter you
17+
want, see [installation instructions]
18+
(http://foshttpcachebundle.readthedocs.org/en/stable/installation.html)
19+
1320
1.3.7
1421
-----
1522

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-
$logListener = $container->getDefinition('fos_http_cache.event_listener.log')
32-
->setAbstract(false);
33-
34-
$container->getDefinition('fos_http_cache.cache_manager')
35-
->addMethodCall('addSubscriber', array($logListener));
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
@@ -360,11 +360,6 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo
360360
if (!empty($config['rules'])) {
361361
$this->loadTagRules($container, $config['rules']);
362362
}
363-
364-
$tagsHeader = $config['header'];
365-
$container->getDefinition($this->getAlias().'.cache_manager')
366-
->addMethodCall('setTagsHeader', array($tagsHeader))
367-
;
368363
}
369364

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

Resources/config/matcher.xml

Lines changed: 2 additions & 0 deletions
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
/>
1718

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/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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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-
1918
</services>
2019

2120
</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
@@ -16,6 +16,8 @@
1616
use FOS\HttpCache\Test\Proxy\ProxyInterface;
1717
use Guzzle\Http\ClientInterface;
1818
use Guzzle\Http\Message\Response;
19+
use Http\Adapter\HttpAdapter;
20+
use Http\Discovery\MessageFactoryDiscovery;
1921
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
2022
use Symfony\Component\DependencyInjection\ContainerInterface;
2123

@@ -71,7 +73,7 @@ public static function isCacheMiss()
7173
* Get HTTP test client for making requests to your application through a
7274
* live caching proxy.
7375
*
74-
* @return ClientInterface
76+
* @return HttpAdapter
7577
*/
7678
protected function getHttpClient()
7779
{
@@ -81,15 +83,22 @@ protected function getHttpClient()
8183
/**
8284
* Get a response from your application through a live caching proxy.
8385
*
84-
* @param string $url Request URL (absolute or relative)
86+
* @param string $uri Request URL (absolute or relative)
8587
* @param array $headers Request HTTP headers
8688
* @param array $options Request options
8789
*
8890
* @return Response
8991
*/
90-
protected function getResponse($url, array $headers = array(), $options = array())
92+
protected function getResponse($uri, array $headers = array())
9193
{
92-
return $this->getHttpClient()->get($url, $headers, $options)->send();
94+
$request = MessageFactoryDiscovery::find()->createRequest(
95+
'GET',
96+
$uri,
97+
'1.1',
98+
$headers
99+
);
100+
101+
return $this->getHttpClient()->sendRequest($request);
93102
}
94103

95104
/**

Tests/Unit/CacheManagerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public function testRefreshRoute()
8888
*/
8989
public function testTagResponse()
9090
{
91+
$this->markTestSkipped('TODO refactor to use tag handler');
9192
$ban = \Mockery::mock(BanInterface::class);
9293
$router = \Mockery::mock(UrlGeneratorInterface::class);
9394

0 commit comments

Comments
 (0)