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\variables; |
||
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 nystudio107\routemap\RouteMap; |
||
15 | |||
16 | /** |
||
0 ignored issues
–
show
|
|||
17 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
18 | * @package RouteMap |
||
0 ignored issues
–
show
|
|||
19 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
20 | */ |
||
0 ignored issues
–
show
|
|||
21 | class RouteMapVariable |
||
22 | { |
||
23 | // Public Methods |
||
24 | // ========================================================================= |
||
25 | /** |
||
26 | * Return the public URLs for all elements that have URLs |
||
27 | * |
||
28 | * @param array $criteria |
||
0 ignored issues
–
show
|
|||
29 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
30 | * @return array |
||
0 ignored issues
–
show
|
|||
31 | */ |
||
32 | public function getAllUrls(array $criteria = [], ?int $siteId = null): array |
||
33 | { |
||
34 | return RouteMap::$plugin->routes->getAllUrls($criteria, $siteId); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Return all the section and category route rules |
||
39 | * |
||
40 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
41 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
42 | * @return array |
||
0 ignored issues
–
show
|
|||
43 | */ |
||
44 | public function getAllRouteRules(string $format = 'Craft', ?int $siteId = null): array |
||
45 | { |
||
46 | return RouteMap::$plugin->routes->getAllRouteRules($format, $siteId); |
||
47 | } |
||
48 | |||
49 | |||
50 | /** |
||
51 | * Return the public URLs for a section |
||
52 | * |
||
53 | * @param string $section |
||
0 ignored issues
–
show
|
|||
54 | * @param array $criteria |
||
0 ignored issues
–
show
|
|||
55 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
56 | * @return array |
||
0 ignored issues
–
show
|
|||
57 | */ |
||
58 | public function getSectionUrls(string $section, array $criteria = [], ?int $siteId = null): array |
||
59 | { |
||
60 | return RouteMap::$plugin->routes->getSectionUrls($section, $criteria, $siteId); |
||
61 | } |
||
62 | |||
63 | |||
64 | /** |
||
65 | * Return all the section route rules |
||
66 | * |
||
67 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
68 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
69 | * @return array |
||
0 ignored issues
–
show
|
|||
70 | */ |
||
71 | public function getAllSectionRouteRules(string $format = 'Craft', ?int $siteId = null): array |
||
72 | { |
||
73 | return RouteMap::$plugin->routes->getAllSectionRouteRules($format, $siteId); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Return the route rules for a specific section |
||
78 | * |
||
79 | * @param string $section |
||
0 ignored issues
–
show
|
|||
80 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
81 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
82 | * @return array |
||
0 ignored issues
–
show
|
|||
83 | */ |
||
84 | public function getSectionRouteRules(string $section, string $format = 'Craft', ?int $siteId = null): array |
||
85 | { |
||
86 | return RouteMap::$plugin->routes->getSectionRouteRules($section, $format, $siteId); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Return the public URLs for a category group |
||
91 | * |
||
92 | * @param string $category |
||
0 ignored issues
–
show
|
|||
93 | * @param array $criteria |
||
0 ignored issues
–
show
|
|||
94 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
95 | * @return array |
||
0 ignored issues
–
show
|
|||
96 | */ |
||
97 | public function getCategoryUrls(string $category, array $criteria = [], ?int $siteId = null): array |
||
98 | { |
||
99 | return RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Return all the cateogry group route rules |
||
104 | * |
||
105 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
106 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
107 | * @return array |
||
0 ignored issues
–
show
|
|||
108 | */ |
||
109 | public function getAllCategoryRouteRules(string $format = 'Craft', ?int $siteId = null): array |
||
110 | { |
||
111 | return RouteMap::$plugin->routes->getAllCategoryRouteRules($format, $siteId); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Return the route rules for a specific category |
||
116 | * |
||
117 | * @param string $category |
||
0 ignored issues
–
show
|
|||
118 | * @param string $format 'Craft'|'React'|'Vue' |
||
0 ignored issues
–
show
|
|||
119 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
120 | * @return array |
||
0 ignored issues
–
show
|
|||
121 | */ |
||
122 | public function getCategoryRouteRules(string $category, string $format = 'Craft', ?int $siteId = null): array |
||
123 | { |
||
124 | return RouteMap::$plugin->routes->getCategoryRouteRules($category, $format, $siteId); |
||
125 | } |
||
126 | |||
127 | |||
128 | /** |
||
129 | * Get all the assets of the type $assetTypes that are used in the Entry |
||
130 | * that matches the $url |
||
131 | * |
||
132 | * @param string $url |
||
0 ignored issues
–
show
|
|||
133 | * @param array $assetTypes |
||
0 ignored issues
–
show
|
|||
134 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
135 | * @return array |
||
0 ignored issues
–
show
|
|||
136 | */ |
||
137 | public function getUrlAssetUrls(string $url, array $assetTypes = ['image'], ?int $siteId = null): array |
||
138 | { |
||
139 | return RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Returns all the URLs for the given $elementType based on the passed in |
||
144 | * $criteria and $siteId |
||
145 | * |
||
146 | * @param string|ElementInterface $elementType |
||
0 ignored issues
–
show
|
|||
147 | * @param array $criteria |
||
0 ignored issues
–
show
|
|||
148 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
149 | * @return array |
||
0 ignored issues
–
show
|
|||
150 | */ |
||
151 | public function getElementUrls(string|ElementInterface $elementType, array $criteria = [], ?int $siteId = null): array |
||
152 | { |
||
153 | return RouteMap::$plugin->routes->getElementUrls($elementType, $criteria, $siteId); |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * Get all routes rules defined in the config/routes.php file and CMS |
||
158 | * |
||
159 | * @param bool $incGlobalRules - merge global routes with the site rules |
||
0 ignored issues
–
show
|
|||
160 | * @param ?int $siteId |
||
0 ignored issues
–
show
|
|||
161 | * @return array |
||
0 ignored issues
–
show
|
|||
162 | */ |
||
163 | public function getRouteRules(?int $siteId = null, bool $incGlobalRules = true): array |
||
164 | { |
||
165 | return RouteMap::$plugin->routes->getRouteRules($siteId, $incGlobalRules); |
||
166 | } |
||
167 | } |
||
168 |