Passed
Push — v3 ( e59c9d...9ad5d8 )
by Andrew
48:27 queued 25:26
created

FrontendTemplateController::actionSecurity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 6
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * SEOmatic plugin for Craft CMS 3.x
4
 *
5
 * @link      https://nystudio107.com/
6
 * @copyright Copyright (c) 2017 nystudio107
7
 * @license   https://nystudio107.com/license
0 ignored issues
show
Coding Style introduced by
@license tag must contain a URL and a license name
Loading history...
8
 */
9
10
namespace nystudio107\seomatic\controllers;
11
12
use nystudio107\seomatic\Seomatic;
13
use nystudio107\seomatic\services\FrontendTemplates;
14
15
use Craft;
16
use craft\web\Controller;
17
18
use yii\web\Response;
19
20
/**
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   Seomatic
23
 * @since     3.0.0
24
 */
25
class FrontendTemplateController extends Controller
26
{
27
    // Properties
28
    // =========================================================================
29
30
    /**
31
     * @inheritdoc
32
     */
33
    protected $allowAnonymous = [
34
        'humans',
35
        'robots',
36
        'ads',
37
        'security',
38
    ];
39
40
    // Public Methods
41
    // =========================================================================
42
43
    /**
44
     * Returns the rendered humans.txt
45
     *
46
     * @return Response
47
     */
48
    public function actionHumans(): Response
49
    {
50
        $text = Seomatic::$plugin->frontendTemplates->renderTemplate(FrontendTemplates::HUMANS_TXT_HANDLE);
51
52
        $headers = Craft::$app->response->headers;
53
        $headers->add('Content-Type', 'text/plain; charset=utf-8');
54
55
        return $this->asRaw($text);
56
    }
57
58
    /**
59
     * Returns the rendered robots.txt
60
     *
61
     * @return Response
62
     */
63
    public function actionRobots(): Response
64
    {
65
        $text = Seomatic::$plugin->frontendTemplates->renderTemplate(FrontendTemplates::ROBOTS_TXT_HANDLE);
66
67
        $headers = Craft::$app->response->headers;
68
        $headers->add('Content-Type', 'text/plain; charset=utf-8');
69
70
        return $this->asRaw($text);
71
    }
72
73
    /**
74
     * Returns the rendered ads.txt
75
     *
76
     * @return Response
77
     */
78
    public function actionAds(): Response
79
    {
80
        $text = Seomatic::$plugin->frontendTemplates->renderTemplate(FrontendTemplates::ADS_TXT_HANDLE);
81
82
        $headers = Craft::$app->response->headers;
83
        $headers->add('Content-Type', 'text/plain; charset=utf-8');
84
85
        return $this->asRaw($text);
86
    }
87
88
    /**
89
     * Returns the rendered security.txt
90
     *
91
     * @return Response
92
     */
93
    public function actionSecurity(): Response
94
    {
95
        $text = Seomatic::$plugin->frontendTemplates->renderTemplate(FrontendTemplates::SECURITY_TXT_HANDLE);
96
97
        $headers = Craft::$app->response->headers;
98
        $headers->add('Content-Type', 'text/plain; charset=utf-8');
99
100
        return $this->asRaw($text);
101
    }
102
103
}
104