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) 2019 nystudio107 |
||||
|
0 ignored issues
–
show
|
|||||
| 10 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 11 | |||||
| 12 | namespace nystudio107\retour\gql\interfaces; |
||||
| 13 | |||||
| 14 | use craft\gql\base\InterfaceType as BaseInterfaceType; |
||||
| 15 | |||||
| 16 | use craft\gql\GqlEntityRegistry; |
||||
| 17 | use GraphQL\Type\Definition\InterfaceType; |
||||
| 18 | |||||
| 19 | use GraphQL\Type\Definition\Type; |
||||
| 20 | use nystudio107\retour\gql\types\generators\RetourGenerator; |
||||
| 21 | |||||
| 22 | /** |
||||
| 23 | * Class RetourInterface |
||||
| 24 | * |
||||
| 25 | * @author nystudio107 |
||||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||||
| 26 | * @package Retour |
||||
|
0 ignored issues
–
show
|
|||||
| 27 | * @since 3.1.26 |
||||
|
0 ignored issues
–
show
|
|||||
| 28 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 29 | class RetourInterface extends BaseInterfaceType |
||||
| 30 | { |
||||
| 31 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 32 | * @inheritdoc |
||||
| 33 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 34 | public static function getTypeGenerator(): string |
||||
| 35 | { |
||||
| 36 | return RetourGenerator::class; |
||||
| 37 | } |
||||
| 38 | |||||
| 39 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 40 | * @inheritdoc |
||||
| 41 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 42 | public static function getType($fields = null): Type |
||||
|
0 ignored issues
–
show
The parameter
$fields is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 43 | { |
||||
| 44 | if ($type = GqlEntityRegistry::getEntity(self::class)) { |
||||
| 45 | return $type; |
||||
| 46 | } |
||||
| 47 | |||||
| 48 | $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([ |
||||
|
0 ignored issues
–
show
|
|||||
| 49 | 'name' => static::getName(), |
||||
| 50 | 'fields' => self::class . '::getFieldDefinitions', |
||||
| 51 | 'description' => 'This is the interface implemented by Retour.', |
||||
| 52 | 'resolveType' => function(array $value) { |
||||
|
0 ignored issues
–
show
The parameter
$value is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 53 | return GqlEntityRegistry::getEntity(RetourGenerator::getName()); |
||||
| 54 | }, |
||||
| 55 | ])); |
||||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||||
| 56 | RetourGenerator::generateTypes(); |
||||
| 57 | |||||
| 58 | return $type; |
||||
| 59 | } |
||||
| 60 | |||||
| 61 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 62 | * @inheritdoc |
||||
| 63 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 64 | public static function getName(): string |
||||
| 65 | { |
||||
| 66 | return 'RetourInterface'; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 70 | * @inheritdoc |
||||
| 71 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 72 | public static function getFieldDefinitions(): array |
||||
| 73 | { |
||||
| 74 | return array_merge(parent::getFieldDefinitions(), [ |
||||
|
0 ignored issues
–
show
|
|||||
| 75 | 'id' => [ |
||||
| 76 | 'name' => 'id', |
||||
| 77 | 'type' => Type::int(), |
||||
| 78 | 'description' => 'The id of the redirect.', |
||||
| 79 | ], |
||||
| 80 | 'site' => [ |
||||
| 81 | 'name' => 'site', |
||||
| 82 | 'type' => Type::string(), |
||||
| 83 | 'description' => 'The site handle of the redirect (or null for all sites).', |
||||
| 84 | ], |
||||
| 85 | 'siteId' => [ |
||||
| 86 | 'name' => 'siteId', |
||||
| 87 | 'type' => Type::int(), |
||||
| 88 | 'description' => 'The siteId of the redirect (0 or null for all sites).', |
||||
| 89 | ], |
||||
| 90 | 'associatedElementId' => [ |
||||
| 91 | 'name' => 'associatedElementId', |
||||
| 92 | 'type' => Type::int(), |
||||
| 93 | 'description' => 'The id of the Element associated with this redirect (unused/vestigial).', |
||||
| 94 | ], |
||||
| 95 | 'enabled' => [ |
||||
| 96 | 'name' => 'enabled', |
||||
| 97 | 'type' => Type::boolean(), |
||||
| 98 | 'description' => 'Whether the redirect is enabled or not.', |
||||
| 99 | ], |
||||
| 100 | 'redirectSrcUrl' => [ |
||||
| 101 | 'name' => 'redirectSrcUrl', |
||||
| 102 | 'type' => Type::string(), |
||||
| 103 | 'description' => 'The unparsed URL pattern that Retour should match.', |
||||
| 104 | ], |
||||
| 105 | 'redirectSrcUrlParsed' => [ |
||||
| 106 | 'name' => 'redirectSrcUrlParsed', |
||||
| 107 | 'type' => Type::string(), |
||||
| 108 | 'description' => 'The parsed URL pattern that Retour should match.', |
||||
| 109 | ], |
||||
| 110 | 'redirectSrcMatch' => [ |
||||
| 111 | 'name' => 'redirectSrcMatch', |
||||
| 112 | 'type' => Type::string(), |
||||
| 113 | 'description' => 'Should the legacy URL be matched by path or by full URL?', |
||||
| 114 | ], |
||||
| 115 | 'redirectMatchType' => [ |
||||
| 116 | 'name' => 'redirectMatchType', |
||||
| 117 | 'type' => Type::string(), |
||||
| 118 | 'description' => 'Whether an `exactmatch` or `regexmatch` should be used when matching the URL.', |
||||
| 119 | ], |
||||
| 120 | 'redirectDestUrl' => [ |
||||
| 121 | 'name' => 'redirectDestUrl', |
||||
| 122 | 'type' => Type::string(), |
||||
| 123 | 'description' => 'The URL that should be redirected to.', |
||||
| 124 | ], |
||||
| 125 | 'redirectHttpCode' => [ |
||||
| 126 | 'name' => 'redirectHttpCode', |
||||
| 127 | 'type' => Type::int(), |
||||
| 128 | 'description' => 'The http status code that should be used for the redirect.', |
||||
| 129 | ], |
||||
| 130 | 'hitCount' => [ |
||||
| 131 | 'name' => 'hitCount', |
||||
| 132 | 'type' => Type::int(), |
||||
| 133 | 'description' => 'The number of times this redirect has been hit.', |
||||
| 134 | ], |
||||
| 135 | 'hitLastTime' => [ |
||||
| 136 | 'name' => 'hitLastTime', |
||||
| 137 | 'type' => Type::string(), |
||||
| 138 | 'description' => 'A datetime string of when this redirect was last hit.', |
||||
| 139 | ], |
||||
| 140 | ]); |
||||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||||
| 141 | } |
||||
| 142 | } |
||||
| 143 |