1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Retour plugin for Craft CMS |
4
|
|
|
* |
5
|
|
|
* Retour allows you to intelligently redirect legacy URLs, so that you don't |
6
|
|
|
* lose SEO value when rebuilding & restructuring a website |
7
|
|
|
* |
8
|
|
|
* @link https://nystudio107.com/ |
|
|
|
|
9
|
|
|
* @copyright Copyright (c) 2018 nystudio107 |
|
|
|
|
10
|
|
|
*/ |
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace nystudio107\retour\services; |
13
|
|
|
|
14
|
|
|
use craft\helpers\ArrayHelper; |
15
|
|
|
use nystudio107\pluginvite\services\VitePluginService; |
16
|
|
|
use nystudio107\retour\assetbundles\retour\RetourAsset; |
17
|
|
|
use yii\base\InvalidConfigException; |
18
|
|
|
|
19
|
|
|
/** |
|
|
|
|
20
|
|
|
* @author nystudio107 |
|
|
|
|
21
|
|
|
* @package Retour |
|
|
|
|
22
|
|
|
* @since 3.2.3 |
|
|
|
|
23
|
|
|
* |
24
|
|
|
* @property Events $events |
25
|
|
|
* @property Redirects $redirects |
26
|
|
|
* @property Statistics $statistics |
27
|
|
|
* @property VitePluginService $vite |
28
|
|
|
*/ |
|
|
|
|
29
|
|
|
trait ServicesTrait |
30
|
|
|
{ |
31
|
|
|
// Public Methods |
32
|
|
|
// ========================================================================= |
33
|
|
|
|
34
|
|
|
/** |
|
|
|
|
35
|
|
|
* @inheritdoc |
36
|
|
|
*/ |
37
|
|
|
public function __construct($id, $parent = null, array $config = []) |
38
|
|
|
{ |
39
|
|
|
// Merge in the passed config, so it our config can be overridden by Plugins::pluginConfigs['vite'] |
40
|
|
|
// ref: https://github.com/craftcms/cms/issues/1989 |
41
|
|
|
$config = ArrayHelper::merge([ |
|
|
|
|
42
|
|
|
'components' => [ |
43
|
|
|
'events' => Events::class, |
44
|
|
|
'redirects' => Redirects::class, |
45
|
|
|
'statistics' => Statistics::class, |
46
|
|
|
// Register the vite service |
47
|
|
|
'vite' => [ |
48
|
|
|
'class' => VitePluginService::class, |
49
|
|
|
'assetClass' => RetourAsset::class, |
50
|
|
|
'useDevServer' => true, |
51
|
|
|
'devServerPublic' => 'http://localhost:3001', |
52
|
|
|
'serverPublic' => 'http://localhost:8000', |
53
|
|
|
'errorEntry' => 'src/js/Retour.js', |
54
|
|
|
'devServerInternal' => 'http://craft-retour-buildchain:3001', |
55
|
|
|
'checkDevServer' => true, |
56
|
|
|
], |
57
|
|
|
] |
58
|
|
|
], $config); |
|
|
|
|
59
|
|
|
|
60
|
|
|
parent::__construct($id, $parent, $config); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Returns the events service |
65
|
|
|
* |
66
|
|
|
* @return Events The events service |
67
|
|
|
* @throws InvalidConfigException |
68
|
|
|
*/ |
69
|
|
|
public function getEvents(): Events |
70
|
|
|
{ |
71
|
|
|
return $this->get('events'); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Returns the redirects service |
76
|
|
|
* |
77
|
|
|
* @return Redirects The redirects service |
78
|
|
|
* @throws InvalidConfigException |
79
|
|
|
*/ |
80
|
|
|
public function getRedirects(): Redirects |
81
|
|
|
{ |
82
|
|
|
return $this->get('redirects'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns the statistics service |
87
|
|
|
* |
88
|
|
|
* @return Statistics The statistics service |
89
|
|
|
* @throws InvalidConfigException |
90
|
|
|
*/ |
91
|
|
|
public function getStatistics(): Statistics |
92
|
|
|
{ |
93
|
|
|
return $this->get('statistics'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Returns the vite service |
98
|
|
|
* |
99
|
|
|
* @return VitePluginService The vite service |
100
|
|
|
* @throws InvalidConfigException |
101
|
|
|
*/ |
102
|
|
|
public function getVite(): VitePluginService |
103
|
|
|
{ |
104
|
|
|
return $this->get('vite'); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|