Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 05ea70c

Browse files
committed
Updated project structure by putting all sources in "src" directory
1 parent 1333f4a commit 05ea70c

31 files changed

+374
-19
lines changed

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@
2828
],
2929
"require": {
3030
"symfony/framework-bundle": "^3.4|^4.0",
31+
"symfony/console": "^3.4|^4.0",
32+
"symfony/dependency-injection": "^3.4|^4.0",
3133
"phpfastcache/phpfastcache": "^7.0"
3234
},
35+
"suggest": {
36+
"symfony/web-profiler-bundle": "To use the data collector."
37+
},
3338
"autoload": {
34-
"psr-4": { "Phpfastcache\\Bundle\\": "" }
39+
"psr-4": { "Phpfastcache\\Bundle\\": "src/" }
3540
}
3641
}
File renamed without changes.

DataCollector/CacheCollector.php renamed to src/DataCollector/CacheCollector.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
namespace Phpfastcache\Bundle\DataCollector;
1818

19-
use Phpfastcache\Api as phpFastCacheApi;
20-
use Phpfastcache\Bundle\phpFastCacheBundle;
21-
use Phpfastcache\Bundle\Service\Cache;
19+
use Phpfastcache\Api as PhpfastcacheApi;
20+
use Phpfastcache\Bundle\PhpfastcacheBundle;
21+
use Phpfastcache\Bundle\Service\Phpfastcache;
2222
use Phpfastcache\CacheManager;
2323
use Symfony\Component\HttpFoundation\Request;
2424
use Symfony\Component\HttpFoundation\Response;
@@ -27,7 +27,7 @@
2727
class CacheCollector extends DataCollector
2828
{
2929
/**
30-
* @var \Phpfastcache\Bundle\Service\Cache
30+
* @var \Phpfastcache\Bundle\Service\Phpfastcache
3131
*/
3232
private $cache;
3333

@@ -39,9 +39,9 @@ class CacheCollector extends DataCollector
3939
/**
4040
* CacheCollector constructor.
4141
*
42-
* @param \Phpfastcache\Bundle\Service\Cache $cache
42+
* @param \Phpfastcache\Bundle\Service\Phpfastcache $cache
4343
*/
44-
public function __construct(Cache $cache)
44+
public function __construct(Phpfastcache $cache)
4545
{
4646
$this->cache = $cache;
4747
}
@@ -66,16 +66,17 @@ public function collect(Request $request, Response $response, \Exception $except
6666
$stats[ $instanceName ] = $cache->getStats();
6767
$instances[ $instanceName ] = [
6868
'driverName' => $cache->getDriverName(),
69-
'driverConfig' => $cache->getConfig(),
69+
'driverConfig' => $cache->getConfig()->toArray(),
7070
];
7171
$driverUsed[ $cache->getDriverName() ] = get_class($cache);
7272
}
7373

7474
$this->data = [
7575
'twigCacheBlocks' => $this->twig_cache_blocks,
76-
'apiVersion' => phpFastCacheApi::getVersion(),
76+
'apiVersion' => PhpfastcacheApi::getVersion(),
77+
'pfcVersion' => PhpfastcacheApi::getPhpFastCacheVersion(),
7778
'bundleVersion' => phpFastCacheBundle::VERSION,
78-
'apiChangelog' => phpFastCacheApi::getChangelog(),
79+
'apiChangelog' => PhpfastcacheApi::getChangelog(),
7980
'driverUsed' => $driverUsed,
8081
'instances' => $instances,
8182
'stats' => $stats,
@@ -85,7 +86,8 @@ public function collect(Request $request, Response $response, \Exception $except
8586
'write' => (int) CacheManager::$WriteHits,
8687
],
8788
'coreConfig' => [
88-
'namespacePath' => CacheManager::getNamespacePath(),
89+
'driverList' => CacheManager::getDriverList(true),
90+
'namespacePath (deprecated)' => CacheManager::getNamespacePath(true),
8991
],
9092
'projectConfig' => [
9193
'twig_driver' => $this->cache->getConfig()['twig_driver'],
@@ -158,6 +160,14 @@ public function getApiVersion()
158160
return $this->data[ 'apiVersion' ];
159161
}
160162

163+
/**
164+
* @return mixed
165+
*/
166+
public function getPfcVersion()
167+
{
168+
return $this->data[ 'pfcVersion' ];
169+
}
170+
161171
/**
162172
* @return mixed
163173
*/

PhpfastcacheBundle.php renamed to src/PhpfastcacheBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
*/
2424
class PhpfastcacheBundle extends Bundle
2525
{
26-
const VERSION = '1.0.4';
26+
const VERSION = '3.0.0-alpha';
2727
}
File renamed without changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Because the V3 is not backward compatible with the V2 we will help you to migrate your code:
2+
3+
4+
### Configuration name:
5+
6+
#### :clock1: Then:
7+
```yaml
8+
# PhpFastCache configuration
9+
php_fast_cache:
10+
twig_driver: "filecache" # This option must be a valid declared driver, in our example: "filecache"
11+
twig_block_debug: true # This option will wrap CACHE/ENDCACHE blocks with block debug as HTML comment
12+
drivers:
13+
filecache:
14+
type: Files
15+
parameters:
16+
path: "%kernel.cache_dir%/phpfastcache/"
17+
```
18+
19+
#### :alarm_clock: Now:
20+
21+
```yaml
22+
# PhpFastCache configuration
23+
phpfastcache:
24+
twig_driver: "filecache" # This option must be a valid declared driver, in our example: "filecache"
25+
twig_block_debug: true # This option will wrap CACHE/ENDCACHE blocks with block debug as HTML comment
26+
drivers:
27+
filecache:
28+
type: Files
29+
parameters:
30+
path: "%kernel.cache_dir%/phpfastcache/"
31+
```
32+
Notice the change from "php_fast_cache" to "phpfastcache".

src/Resources/config/services.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
parameters:
2+
php_fast_cache.phpfastcache.class: Phpfastcache\Bundle\Service\Phpfastcache
3+
php_fast_cache.human_readable.class: Phpfastcache\Bundle\Twig\HumanReadableExtension\Extension
4+
php_fast_cache.twig_cache.class: Phpfastcache\Bundle\Twig\CacheExtension\Extension
5+
php_fast_cache.twig_cache_stategy.class: Phpfastcache\Bundle\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy
6+
php_fast_cache.twig_cache_provider.class: Phpfastcache\Bundle\Twig\CacheExtension\CacheProvider\PsrCacheAdapter
7+
8+
services:
9+
Phpfastcache\Bundle\Service\Phpfastcache:
10+
autowire: true
11+
public: false
12+
arguments:
13+
- "%phpfastcache%"
14+
- "@?debug.stopwatch"
15+
phpfastcache.human_readable_size:
16+
class: "%php_fast_cache.human_readable.class%"
17+
tags:
18+
- { name: twig.extension }
19+
phpfastcache.twig_cache_driver_provider:
20+
class: "%php_fast_cache.phpfastcache.class%"
21+
factory: 'Phpfastcache\Bundle\Service\Phpfastcache:getTwigCacheInstance'
22+
phpfastcache.twig_cache_provider:
23+
class: "%php_fast_cache.twig_cache_provider.class%"
24+
arguments:
25+
- "@phpfastcache.twig_cache_driver_provider"
26+
phpfastcache.twig_cache_stategy:
27+
class: "%php_fast_cache.twig_cache_stategy.class%"
28+
arguments:
29+
- "@phpfastcache.twig_cache_provider"
30+
- "@?phpfastcache.request_collector"
31+
- "%phpfastcache%"
32+
twig.extension.cache:
33+
class: "%php_fast_cache.twig_cache.class%"
34+
arguments:
35+
- "@phpfastcache.twig_cache_stategy"
36+
tags:
37+
- { name: twig.extension }

src/Resources/config/services_dev.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
parameters:
2+
php_fast_cache.data_collector.class: Phpfastcache\Bundle\DataCollector\CacheCollector
3+
4+
services:
5+
data_collector.phpfastcache:
6+
class: "%php_fast_cache.data_collector.class%"
7+
arguments:
8+
- '@Phpfastcache\Bundle\Service\Phpfastcache'
9+
public: false
10+
tags:
11+
-
12+
name: data_collector
13+
template: "@Phpfastcache/Collector/cache.html.twig"
14+
id: 'phpfastcache'
15+
priority: 300

0 commit comments

Comments
 (0)