Passed
Branch v1 (0c7460)
by Andrew
06:14
created

CpNavController::actionResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
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\transcoder\controllers;
12
13
use Craft;
14
use craft\web\Controller;
15
16
use yii\web\Response;
17
18
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
 * @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...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   Retour
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     3.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 */
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...
23
class CpNavController extends Controller
24
{
25
    // Constants
26
    // =========================================================================
27
28
    // Protected Properties
29
    // =========================================================================
30
31
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
32
     * @var    bool|array Allows anonymous access to this controller's actions.
33
     *         The actions must be in 'kebab-case'
34
     * @access protected
35
     */
36
    protected $allowAnonymous = [
37
        'resource'
38
    ];
39
40
    // Public Methods
41
    // =========================================================================
42
43
    /**
44
     * Make webpack async bundle loading work out of published AssetBundles
45
     *
46
     * @param string $resourceType
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
47
     * @param string $fileName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
48
     *
49
     * @return Response
50
     */
51
    public function actionResource(string $resourceType = '', string $fileName = ''): Response
52
    {
53
        $baseAssetsUrl = Craft::$app->assetManager->getPublishedUrl(
54
            '@nystudio107/transcoder/assetbundles/transcoder/dist',
55
            true
56
        );
57
        $url = "{$baseAssetsUrl}/{$resourceType}/{$fileName}";
58
59
        return $this->redirect($url);
60
    }
61
}
62