Passed
Push — develop ( 1fd00d...bbfe99 )
by Andrew
04:32
created

CpNavController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 8
dl 0
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A actionResource() 0 9 1
1
<?php
2
/**
3
 * ImageOptimize plugin for Craft CMS 3.x
4
 *
5
 * Automatically optimize images after they've been transformed
6
 *
7
 * @link      https://nystudio107.com
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2017 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\imageoptimize\controllers;
12
13
use nystudio107\imageoptimize\ImageOptimize;
14
15
use Craft;
16
use craft\web\Controller;
17
18
use yii\web\Response;
19
20
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
22
 * @package   Retour
23
 * @since     3.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
24
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
25
class CpNavController extends Controller
26
{
27
    // Constants
28
    // =========================================================================
29
30
    // Protected Properties
31
    // =========================================================================
32
33
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
34
     * @var    bool|array Allows anonymous access to this controller's actions.
35
     *         The actions must be in 'kebab-case'
36
     * @access protected
37
     */
38
    protected $allowAnonymous = [
39
        'resource'
40
    ];
41
42
    // Public Methods
43
    // =========================================================================
44
45
    /**
46
     * Make webpack async bundle loading work out of published AssetBundles
47
     *
48
     * @param string $resourceType
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
49
     * @param string $fileName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
50
     *
51
     * @return Response
52
     */
53
    public function actionResource(string $resourceType = '', string $fileName = ''): Response
54
    {
55
        $baseAssetsUrl = Craft::$app->assetManager->getPublishedUrl(
56
            '@nystudio107/imageoptimize/assetbundles/imageoptimize/dist',
57
            true
58
        );
59
        $url = "{$baseAssetsUrl}/{$resourceType}/{$fileName}";
60
61
        return $this->redirect($url);
62
    }
63
}
64