Plugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
dl 0
loc 34
rs 10
c 1
b 0
f 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureCache() 0 15 2
A bootstrap() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Saito - The Threaded Web Forum
7
 *
8
 * @copyright Copyright (c) the Saito Project Developers
9
 * @link https://github.com/Schlaefer/Saito
10
 * @license http://opensource.org/licenses/MIT
11
 */
12
13
namespace ImageUploader;
14
15
use Cake\Cache\Cache;
16
use Cake\Core\BasePlugin;
17
use Cake\Core\Configure;
18
use Cake\Core\PluginApplicationInterface;
19
20
class Plugin extends BasePlugin
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function bootstrap(PluginApplicationInterface $app)
26
    {
27
        // Add constants, load configuration defaults.
28
        // By default will load `config/bootstrap.php` in the plugin.
29
        parent::bootstrap($app);
30
31
        self::configureCache();
32
    }
33
34
    /**
35
     * Configures the thumbnail cache
36
     *
37
     * @return void
38
     */
39
    public static function configureCache(): void
40
    {
41
        $cacheKey = Configure::read('Saito.Settings.uploader')->getCacheKey();
42
        if (Cache::getConfig($cacheKey) !== null) {
43
            return;
44
        }
45
46
        Cache::setConfig(
47
            $cacheKey,
48
            [
49
                'className' => 'File',
50
                'prefix' => 'saito_thumbnails-',
51
                'path' => CACHE,
52
                'groups' => ['uploads'],
53
                'duration' => '+1 year',
54
            ]
55
        );
56
    }
57
}
58