Skip to content

Commit d676984

Browse files
author
Vincent Chalnot
committed
Moving cache dependencies to a dedicated bundle
0 parents  commit d676984

29 files changed

+2137
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor

CleverAgeCacheProcessBundle.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of the CleverAge/CacheProcessBundle package.
4+
*
5+
* Copyright (C) 2017-2019 Clever-Age
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace CleverAge\CacheProcessBundle;
12+
13+
use Symfony\Component\HttpKernel\Bundle\Bundle;
14+
15+
/**
16+
* Class CleverAgeCacheProcessBundle
17+
*
18+
* @author Valentin Clavreul <[email protected]>
19+
* @author Vincent Chalnot <[email protected]>
20+
* @author Madeline Veyrenc <[email protected]>
21+
*/
22+
class CleverAgeCacheProcessBundle extends Bundle
23+
{
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of the CleverAge/CacheProcessBundle package.
4+
*
5+
* Copyright (C) 2017-2019 Clever-Age
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace CleverAge\CacheProcessBundle\DependencyInjection;
12+
13+
use Sidus\BaseBundle\DependencyInjection\SidusBaseExtension;
14+
15+
/**
16+
* This is the class that loads and manages your bundle configuration.
17+
*
18+
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html
19+
*
20+
* @author Valentin Clavreul <[email protected]>
21+
* @author Vincent Chalnot <[email protected]>
22+
* @author Madeline Veyrenc <[email protected]>
23+
*/
24+
class CleverAgeCacheProcessExtension extends SidusBaseExtension
25+
{
26+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of the CleverAge/ProcessBundle package.
4+
*
5+
* Copyright (C) 2017-2019 Clever-Age
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace CleverAge\CacheProcessBundle\DependencyInjection\Compiler;
12+
13+
use Psr\Cache\CacheItemPoolInterface;
14+
use Symfony\Component\DependencyInjection\ChildDefinition;
15+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
18+
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
19+
use Symfony\Contracts\Cache\CacheInterface;
20+
21+
/**
22+
* Generic compiler pass to add tagged services to a registry
23+
*
24+
* @author Madeline Veyrenc <[email protected]>
25+
*/
26+
class CachePoolPass implements CompilerPassInterface
27+
{
28+
/**
29+
* Inject tagged services into defined registry
30+
*
31+
* @param ContainerBuilder $container
32+
*
33+
* @throws InvalidArgumentException
34+
* @throws \UnexpectedValueException
35+
* @throws ServiceNotFoundException
36+
* @throws \Exception
37+
* @api
38+
*
39+
*/
40+
public function process(ContainerBuilder $container)
41+
{
42+
$name = 'cache.app.cleverage_process';
43+
$pool = [
44+
'adapter' => 'cache.app',
45+
'public' => true,
46+
];
47+
$definition = new ChildDefinition($pool['adapter']);
48+
$container->registerAliasForArgument($name, CacheInterface::class);
49+
$container->registerAliasForArgument($name, CacheItemPoolInterface::class);
50+
$definition->setPublic($pool['public']);
51+
52+
$definition->addTag('cache.pool');
53+
$container->setDefinition($name, $definition);
54+
}
55+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2015-2019 Clever-Age
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.

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
CleverAge/CacheProcessBundle
2+
=======================
3+
4+
See process bundle documentation
5+
6+
## Help needed
7+
8+
This bundle is a mess, it doesn't require the proper dependencies, it uses missing methods (transformValue), there is a
9+
general lack of comments and annotations and it needs to be properly migrated to PHP7.1+.
10+
11+
Also we need to check if tests are ok.
12+
13+
## Documentation
14+
15+
Contains tasks and transformers to handle cache.
16+
17+
Activation
18+
----------
19+
20+
Activated if cache pool `cleverage_process` is defined.
21+
22+
Task reference
23+
--------------
24+
25+
* **Service**: `CleverAge\ProcessBundle\Transformer\ArrayFilterTransformer`
26+
* **Transformer code**: `array_filter`
27+
28+
Accepted inputs
29+
---------------
30+
31+
`array` or `\Iterable`
32+
33+
Possible outputs
34+
----------------
35+
36+
`array` containing only filtered data
37+
38+
Options
39+
-------
40+
41+
| Code | Type | Required | Default | Description |
42+
| ---- | ---- | :------: | ------- | ----------- |
43+
| `condition` | `array` | | `[]` | See [ConditionTrait](TODO) |
44+
____

Resources/config/services/task.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
CleverAge\CacheProcessBundle\Task\:
3+
resource: '../../../Task/*'
4+
autowire: true
5+
public: true
6+
shared: false
7+
arguments:
8+
$cache: '@cache.app'
9+
tags:
10+
- { name: monolog.logger, channel: cleverage_process_task }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
CleverAge\CacheProcessBundle\Transformer\:
3+
resource: '../../../Transformer/*'
4+
autowire: true
5+
public: false
6+
arguments:
7+
$cache: '@cache.app'
8+
tags:
9+
- { name: cleverage.transformer }
10+
- { name: monolog.logger, channel: cleverage_process_transformer }
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
clever_age_process:
2+
configurations:
3+
test.cache_deleter_task.delete_existing_cache:
4+
entry_point: get_cache
5+
end_point: dummy
6+
tasks:
7+
get_cache:
8+
service: '@CleverAge\CacheProcessBundle\Task\DeleterTask'
9+
options:
10+
key:
11+
constant: 'DeleterTaskTest_testDeleteExistingCache'
12+
outputs: [dummy]
13+
14+
dummy:
15+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
16+
17+
test.cache_deleter_task.delete_missing_cache:
18+
entry_point: get_cache
19+
end_point: dummy
20+
tasks:
21+
get_cache:
22+
service: '@CleverAge\CacheProcessBundle\Task\DeleterTask'
23+
options:
24+
key:
25+
constant: 'DeleterTaskTest_testDeleteMissingCache'
26+
outputs: [dummy]
27+
28+
dummy:
29+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
30+
31+
test.cache_deleter_task.transform_cache_key:
32+
entry_point: get_cache
33+
end_point: dummy
34+
tasks:
35+
get_cache:
36+
service: '@CleverAge\CacheProcessBundle\Task\DeleterTask'
37+
options:
38+
key:
39+
transformers:
40+
implode:
41+
separator: '_'
42+
outputs: [dummy]
43+
44+
dummy:
45+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
46+
47+
test.cache_deleter_task.bad_cache_key:
48+
entry_point: get_cache
49+
end_point: dummy
50+
tasks:
51+
get_cache:
52+
service: '@CleverAge\CacheProcessBundle\Task\DeleterTask'
53+
options:
54+
key: ~
55+
outputs: [dummy]
56+
error_outputs: [missing_cache]
57+
58+
missing_cache:
59+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
60+
options:
61+
output: 'missing cache'
62+
outputs: [dummy]
63+
64+
dummy:
65+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
clever_age_process:
2+
configurations:
3+
test.cache_getter_task.get_existing_cache:
4+
entry_point: get_cache
5+
end_point: dummy
6+
tasks:
7+
get_cache:
8+
service: '@CleverAge\CacheProcessBundle\Task\GetterTask'
9+
options:
10+
key:
11+
constant: 'GetterTaskTest_testGetExistingCache'
12+
outputs: [dummy]
13+
error_outputs: [missing_cache]
14+
15+
missing_cache:
16+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
17+
options:
18+
output: 'missing cache'
19+
outputs: [dummy]
20+
21+
dummy:
22+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
23+
24+
test.cache_getter_task.get_missing_cache:
25+
entry_point: get_cache
26+
end_point: dummy
27+
tasks:
28+
get_cache:
29+
service: '@CleverAge\CacheProcessBundle\Task\GetterTask'
30+
options:
31+
key:
32+
constant: 'GetterTaskTest_testGetMissingCache'
33+
outputs: [dummy]
34+
error_outputs: [missing_cache]
35+
36+
missing_cache:
37+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
38+
options:
39+
output: 'missing cache'
40+
outputs: [dummy]
41+
42+
dummy:
43+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
44+
45+
test.cache_getter_task.transform_cache_key:
46+
entry_point: get_cache
47+
end_point: dummy
48+
tasks:
49+
get_cache:
50+
service: '@CleverAge\CacheProcessBundle\Task\GetterTask'
51+
options:
52+
key:
53+
transformers:
54+
implode:
55+
separator: '_'
56+
outputs: [dummy]
57+
error_outputs: [missing_cache]
58+
59+
missing_cache:
60+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
61+
options:
62+
output: 'missing cache'
63+
outputs: [dummy]
64+
65+
dummy:
66+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
67+
68+
test.cache_getter_task.bad_cache_key:
69+
entry_point: get_cache
70+
end_point: dummy
71+
tasks:
72+
get_cache:
73+
service: '@CleverAge\CacheProcessBundle\Task\GetterTask'
74+
options:
75+
key: ~
76+
outputs: [dummy]
77+
error_outputs: [missing_cache]
78+
79+
missing_cache:
80+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
81+
options:
82+
output: 'missing cache'
83+
outputs: [dummy]
84+
85+
dummy:
86+
service: '@CleverAge\ProcessBundle\Task\DummyTask'

0 commit comments

Comments
 (0)