nystudio107 /
craft-retour
| 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/ |
||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
| 9 | * @copyright Copyright (c) 2018 nystudio107 |
||||
|
0 ignored issues
–
show
|
|||||
| 10 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 11 | |||||
| 12 | namespace nystudio107\retour\services; |
||||
| 13 | |||||
| 14 | use nystudio107\pluginvite\services\VitePluginService; |
||||
| 15 | use nystudio107\retour\assetbundles\retour\RetourAsset; |
||||
| 16 | use yii\base\InvalidConfigException; |
||||
| 17 | |||||
| 18 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 19 | * @author nystudio107 |
||||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||||
| 20 | * @package Retour |
||||
|
0 ignored issues
–
show
|
|||||
| 21 | * @since 4.1.4 |
||||
|
0 ignored issues
–
show
|
|||||
| 22 | * |
||||
| 23 | * @property Events $events |
||||
| 24 | * @property Redirects $redirects |
||||
| 25 | * @property Statistics $statistics |
||||
| 26 | * @property VitePluginService $vite |
||||
| 27 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 28 | trait ServicesTrait |
||||
| 29 | { |
||||
| 30 | // Public Static Methods |
||||
| 31 | // ========================================================================= |
||||
| 32 | |||||
| 33 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 34 | * @inheritdoc |
||||
| 35 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 36 | public static function config(): array |
||||
| 37 | { |
||||
| 38 | // Constants aren't allowed in traits until PHP >= 8.2, and config() is called before __construct(), |
||||
| 39 | // so we can't extract it from the passed in $config |
||||
| 40 | $majorVersion = '5'; |
||||
| 41 | // Dev server container name & port are based on the major version of this plugin |
||||
| 42 | $devPort = 3000 + (int)$majorVersion; |
||||
| 43 | $versionName = 'v' . $majorVersion; |
||||
| 44 | return [ |
||||
| 45 | 'components' => [ |
||||
| 46 | 'events' => Events::class, |
||||
| 47 | 'redirects' => Redirects::class, |
||||
| 48 | 'statistics' => Statistics::class, |
||||
| 49 | // Register the vite service |
||||
| 50 | 'vite' => [ |
||||
| 51 | 'assetClass' => RetourAsset::class, |
||||
| 52 | 'checkDevServer' => true, |
||||
| 53 | 'class' => VitePluginService::class, |
||||
| 54 | 'devServerInternal' => 'http://craft-retour-' . $versionName . '-buildchain-dev:' . $devPort, |
||||
| 55 | 'devServerPublic' => 'http://localhost:' . $devPort, |
||||
| 56 | 'errorEntry' => 'src/js/Retour.js', |
||||
| 57 | 'useDevServer' => true, |
||||
| 58 | ], |
||||
| 59 | ], |
||||
| 60 | ]; |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | // Public Methods |
||||
| 64 | // ========================================================================= |
||||
| 65 | |||||
| 66 | /** |
||||
| 67 | * Returns the events service |
||||
| 68 | * |
||||
| 69 | * @return Events The events service |
||||
| 70 | * @throws InvalidConfigException |
||||
| 71 | */ |
||||
| 72 | public function getEvents(): Events |
||||
| 73 | { |
||||
| 74 | return $this->get('events'); |
||||
|
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 75 | } |
||||
| 76 | |||||
| 77 | /** |
||||
| 78 | * Returns the redirects service |
||||
| 79 | * |
||||
| 80 | * @return Redirects The redirects service |
||||
| 81 | * @throws InvalidConfigException |
||||
| 82 | */ |
||||
| 83 | public function getRedirects(): Redirects |
||||
| 84 | { |
||||
| 85 | return $this->get('redirects'); |
||||
| 86 | } |
||||
| 87 | |||||
| 88 | /** |
||||
| 89 | * Returns the statistics service |
||||
| 90 | * |
||||
| 91 | * @return Statistics The statistics service |
||||
| 92 | * @throws InvalidConfigException |
||||
| 93 | */ |
||||
| 94 | public function getStatistics(): Statistics |
||||
| 95 | { |
||||
| 96 | return $this->get('statistics'); |
||||
| 97 | } |
||||
| 98 | |||||
| 99 | /** |
||||
| 100 | * Returns the vite service |
||||
| 101 | * |
||||
| 102 | * @return VitePluginService The vite service |
||||
| 103 | * @throws InvalidConfigException |
||||
| 104 | */ |
||||
| 105 | public function getVite(): VitePluginService |
||||
| 106 | { |
||||
| 107 | return $this->get('vite'); |
||||
| 108 | } |
||||
| 109 | } |
||||
| 110 |