1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SEOmatic plugin for Craft CMS 3.x |
4
|
|
|
* |
5
|
|
|
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, |
6
|
|
|
* and flexible |
7
|
|
|
* |
8
|
|
|
* @link https://nystudio107.com |
9
|
|
|
* @copyright Copyright (c) 2017 nystudio107 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace nystudio107\seomatic\base; |
13
|
|
|
|
14
|
|
|
use nystudio107\seomatic\helpers\PluginTemplate; |
15
|
|
|
use nystudio107\seomatic\Seomatic; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author nystudio107 |
19
|
|
|
* @package Seomatic |
20
|
|
|
* @since 3.0.0 |
21
|
|
|
*/ |
22
|
|
|
abstract class FrontendTemplate extends FluentModel implements FrontendTemplateInterface |
23
|
|
|
{ |
24
|
|
|
// Traits |
25
|
|
|
// ========================================================================= |
26
|
|
|
|
27
|
|
|
use FrontendTemplateTrait; |
28
|
|
|
|
29
|
|
|
// Public Methods |
30
|
|
|
// ========================================================================= |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @inheritdoc |
34
|
|
|
*/ |
35
|
|
|
public function rules(): array |
36
|
|
|
{ |
37
|
|
|
$rules = parent::rules(); |
38
|
|
|
$rules = array_merge($rules, [ |
39
|
|
|
[['include'], 'boolean'], |
40
|
|
|
[['path', 'controller', 'action'], 'required'], |
41
|
|
|
[['path', 'controller', 'action'], 'string'], |
42
|
|
|
]); |
43
|
|
|
|
44
|
|
|
return $rules; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @inheritdoc |
49
|
|
|
*/ |
50
|
|
|
public function routeRules(): array |
51
|
|
|
{ |
52
|
|
|
$rules = []; |
53
|
|
|
$route = |
54
|
|
|
Seomatic::$plugin->handle |
55
|
|
|
. '/' |
56
|
|
|
. $this->controller |
57
|
|
|
. '/' |
58
|
|
|
. $this->action; |
59
|
|
|
$rules[$this->path] = ['route' => $route]; |
60
|
|
|
|
61
|
|
|
return $rules; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @inheritdoc |
66
|
|
|
*/ |
67
|
|
|
public function render(array $params = []): string |
68
|
|
|
{ |
69
|
|
|
return PluginTemplate::renderPluginTemplate($this->path, $params); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|