1 | <?php |
||
2 | /** |
||
3 | * Route Map plugin for Craft CMS |
||
4 | * |
||
5 | * Returns a list of public routes for elements with URLs |
||
6 | * |
||
7 | * @link https://nystudio107.com/ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | * @copyright Copyright (c) 2017 nystudio107 |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | namespace nystudio107\routemap\controllers; |
||
12 | |||
13 | use craft\base\ElementInterface; |
||
0 ignored issues
–
show
The type
craft\base\ElementInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | use craft\web\Controller; |
||
15 | use nystudio107\routemap\RouteMap; |
||
16 | use yii\web\Response; |
||
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]>"
![]() |
|||
20 | * @package RouteMap |
||
0 ignored issues
–
show
|
|||
21 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
22 | */ |
||
0 ignored issues
–
show
|
|||
23 | class RoutesController extends Controller |
||
24 | { |
||
25 | // Protected Properties |
||
26 | // ========================================================================= |
||
27 | |||
28 | protected array|bool|int $allowAnonymous = [ |
||
29 | 'get-all-urls', |
||
30 | 'get-section-urls', |
||
31 | 'get-all-route-rules', |
||
32 | 'get-section-route-rules', |
||
33 | 'get-url-asset-urls', |
||
34 | 'get-element-urls', |
||
35 | ]; |
||
36 | |||
37 | // Public Methods |
||
38 | // ========================================================================= |
||
39 | /** |
||
0 ignored issues
–
show
|
|||
40 | * Return the public URLs for all elements that have URLs |
||
41 | */ |
||
0 ignored issues
–
show
|
|||
42 | public function actionGetAllUrls(array $criteria = [], ?int $siteId = null): Response |
||
43 | { |
||
44 | return $this->asJson(RouteMap::$plugin->routes->getAllUrls($criteria, $siteId)); |
||
45 | } |
||
46 | |||
47 | /** |
||
0 ignored issues
–
show
|
|||
48 | * Return the public URLs for a section |
||
49 | */ |
||
0 ignored issues
–
show
|
|||
50 | public function actionGetSectionUrls(string $section, array $criteria = [], ?int $siteId = null): Response |
||
51 | { |
||
52 | return $this->asJson(RouteMap::$plugin->routes->getSectionUrls($section, $criteria, $siteId)); |
||
53 | } |
||
54 | |||
55 | /** |
||
0 ignored issues
–
show
|
|||
56 | * Return the public URLs for a category |
||
57 | */ |
||
0 ignored issues
–
show
|
|||
58 | public function actionGetCategoryUrls(string $category, array $criteria = [], ?int $siteId = null): Response |
||
59 | { |
||
60 | return $this->asJson(RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId)); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Return all the section route rules |
||
65 | * |
||
66 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
67 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
68 | * @return Response |
||
0 ignored issues
–
show
|
|||
69 | */ |
||
70 | public function actionGetAllRouteRules(string $format = 'Craft', ?int $siteId = null): Response |
||
71 | { |
||
72 | return $this->asJson(RouteMap::$plugin->routes->getAllRouteRules($format, $siteId)); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Return the route rules for a specific section |
||
77 | * |
||
78 | * @param string $section |
||
0 ignored issues
–
show
|
|||
79 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
80 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
81 | * @return Response |
||
0 ignored issues
–
show
|
|||
82 | */ |
||
83 | public function actionGetSectionRouteRules(string $section, string $format = 'Craft', ?int $siteId = null): Response |
||
84 | { |
||
85 | return $this->asJson(RouteMap::$plugin->routes->getSectionRouteRules($section, $format, $siteId)); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Return the route rules for a specific category |
||
90 | * |
||
91 | * @param string $category |
||
0 ignored issues
–
show
|
|||
92 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
93 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
94 | * @return Response |
||
0 ignored issues
–
show
|
|||
95 | */ |
||
96 | public function actionGetCategoryRouteRules(string $category, string $format = 'Craft', ?int $siteId = null): Response |
||
97 | { |
||
98 | return $this->asJson(RouteMap::$plugin->routes->getCategoryRouteRules($category, $format, $siteId)); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Return the Craft Control Panel and `routes.php` rules |
||
103 | * |
||
104 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
105 | * @param bool $includeGlobal |
||
0 ignored issues
–
show
|
|||
106 | * @return Response |
||
0 ignored issues
–
show
|
|||
107 | */ |
||
108 | public function actionGetRouteRules(?int $siteId = null, bool $includeGlobal = true): Response |
||
109 | { |
||
110 | return $this->asJson(RouteMap::$plugin->routes->getRouteRules($siteId, $includeGlobal)); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Get all the assets of the type $assetTypes that are used in the Entry |
||
115 | * that matches the $url |
||
116 | * |
||
117 | * @param string $url |
||
0 ignored issues
–
show
|
|||
118 | * @param array $assetTypes |
||
0 ignored issues
–
show
|
|||
119 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
120 | * @return Response |
||
0 ignored issues
–
show
|
|||
121 | */ |
||
122 | public function actionGetUrlAssetUrls(string $url, array $assetTypes = ['image'], ?int $siteId = null): Response |
||
123 | { |
||
124 | return $this->asJson(RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId)); |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Returns all of the URLs for the given $elementType based on the passed in |
||
129 | * $criteria and $siteId |
||
130 | * |
||
131 | * @param string|ElementInterface $elementType |
||
0 ignored issues
–
show
|
|||
132 | * @param array $criteria |
||
0 ignored issues
–
show
|
|||
133 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
134 | * @return Response |
||
0 ignored issues
–
show
|
|||
135 | */ |
||
136 | public function actionGetElementUrls(string|ElementInterface $elementType, array $criteria = [], ?int $siteId = null): Response |
||
137 | { |
||
138 | return $this->asJson(RouteMap::$plugin->routes->getElementUrls($elementType, $criteria, $siteId)); |
||
139 | } |
||
140 | } |
||
141 |