55use Illuminate \Contracts \View \Factory as ViewFactory ;
66use Illuminate \Support \Facades \Date ;
77
8- if (! function_exists ('app_path ' )) {
8+ if (!function_exists ('app_path ' )) {
99 /**
1010 * Get the path to the application folder.
1111 *
1414 */
1515 function app_path ($ path = '' )
1616 {
17- return app ('path ' ). ($ path ? DIRECTORY_SEPARATOR . $ path : $ path );
17+ return app ('path ' ) . ($ path ? DIRECTORY_SEPARATOR . $ path : $ path );
1818 }
1919}
2020
21- if (! function_exists ('config_path ' )) {
21+ if (!function_exists ('config_path ' )) {
2222 /**
2323 * Get the configuration path.
2424 *
@@ -33,7 +33,7 @@ function config_path($path = '', $custom = false)
3333 }
3434}
3535
36- if (! function_exists ('storage_path ' ))
36+ if (!function_exists ('storage_path ' ))
3737{
3838 /**
3939 * Get the path to the storage folder.
@@ -42,11 +42,11 @@ function config_path($path = '', $custom = false)
4242 */
4343 function storage_path ($ path = '' )
4444 {
45- return app ('path.storage ' ).( $ path ? ' / ' . $ path : $ path) ;
45+ return rtrim ( app ('path.storage ' ), DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . $ path ;
4646 }
4747}
4848
49- if (! function_exists ('base_path ' )) {
49+ if (!function_exists ('base_path ' )) {
5050 /**
5151 * Get the path to the base of the install.
5252 *
@@ -59,7 +59,7 @@ function base_path($path = '')
5959 }
6060}
6161
62- if (! function_exists ('public_path ' )) {
62+ if (!function_exists ('public_path ' )) {
6363 /**
6464 * Get the path to the base of the install with assets.
6565 *
@@ -72,7 +72,7 @@ function public_path($path = '')
7272 }
7373}
7474
75- if (! function_exists ('resource_path ' )) {
75+ if (!function_exists ('resource_path ' )) {
7676 /**
7777 * Get the path to the base of the install with assets.
7878 *
@@ -95,11 +95,11 @@ function resource_path($path = '')
9595 function asset ($ path = '' )
9696 {
9797 $ path = 'assets/ ' . $ path ;
98- return MODX_SITE_URL . ltrim (($ path ? DIRECTORY_SEPARATOR . $ path : $ path ), '/ ' );
98+ return EVO_SITE_URL . ltrim (($ path ? DIRECTORY_SEPARATOR . $ path : $ path ), '/ ' );
9999 }
100100}
101101
102- if (! function_exists ('config ' )) {
102+ if (!function_exists ('config ' )) {
103103 /**
104104 * Get / set the specified configuration value.
105105 *
@@ -123,7 +123,7 @@ function config($key = null, $default = null)
123123 }
124124}
125125
126- if (! function_exists ('app ' )) {
126+ if (!function_exists ('app ' )) {
127127 /**
128128 * Get the available container instance.
129129 *
@@ -142,7 +142,7 @@ function app($abstract = null, array $parameters = [])
142142}
143143
144144
145- if (! function_exists ('back ' )) {
145+ if (!function_exists ('back ' )) {
146146 /**
147147 * Create a new redirect response to the previous location.
148148 *
@@ -157,7 +157,7 @@ function back($status = 302, $headers = [], $fallback = false)
157157 }
158158}
159159
160- if (! function_exists ('cookie ' )) {
160+ if (!function_exists ('cookie ' )) {
161161 /**
162162 * Create a new cookie instance.
163163 *
@@ -184,7 +184,7 @@ function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain
184184 }
185185}
186186
187- if (! function_exists ('csrf_field ' )) {
187+ if (!function_exists ('csrf_field ' )) {
188188 /**
189189 * Generate a CSRF token form field.
190190 *
@@ -196,7 +196,7 @@ function csrf_field()
196196 }
197197}
198198
199- if (! function_exists ('csrf_token ' )) {
199+ if (!function_exists ('csrf_token ' )) {
200200 /**
201201 * Get the CSRF token value.
202202 *
@@ -217,7 +217,7 @@ function csrf_token()
217217 }
218218}
219219
220- if (! function_exists ('now ' )) {
220+ if (!function_exists ('now ' )) {
221221 /**
222222 * Create a new Carbon instance for the current time.
223223 *
@@ -230,7 +230,7 @@ function now($tz = null)
230230 }
231231}
232232
233- if (! function_exists ('old ' )) {
233+ if (!function_exists ('old ' )) {
234234 /**
235235 * Retrieve an old input item.
236236 *
@@ -244,7 +244,7 @@ function old($key = null, $default = null)
244244 }
245245}
246246
247- if (! function_exists ('redirect ' )) {
247+ if (!function_exists ('redirect ' )) {
248248 /**
249249 * Get an instance of the redirector.
250250 *
@@ -264,7 +264,7 @@ function redirect($to = null, $status = 302, $headers = [], $secure = null)
264264 }
265265}
266266
267- if (! function_exists ('request ' )) {
267+ if (!function_exists ('request ' )) {
268268 /**
269269 * Get an instance of the current request or an input item from the request.
270270 *
@@ -288,7 +288,7 @@ function request($key = null, $default = null)
288288 }
289289}
290290
291- if (! function_exists ('response ' )) {
291+ if (!function_exists ('response ' )) {
292292 /**
293293 * Return a new response from the application.
294294 *
@@ -309,27 +309,43 @@ function response($content = '', $status = 200, array $headers = [])
309309 }
310310}
311311
312- if (! function_exists ('route ' )) {
312+ if (!function_exists ('route ' )) {
313313 /**
314314 * Generate the URL to a named route.
315315 *
316- * @param array|string $name
317- * @param mixed $parameters
318- * @param bool $absolute
319- * @return string
316+ * This function automatically handles friendly URL suffixes based on route middleware.
317+ * Routes with 'mgr' middleware or parameters will not receive the friendly_url_suffix.
318+ * Frontend routes will continue to receive the configured suffix (e.g., .html).
319+ *
320+ * @param array|string $name Route name
321+ * @param mixed $parameters Route parameters (if any, suffix is automatically disabled)
322+ * @param bool $absolute Whether to generate absolute URL
323+ * @return string Generated URL with appropriate suffix handling
320324 */
321325 function route ($ name , $ parameters = [], $ absolute = true )
322326 {
323- $ suffix = count ($ parameters ) ? '' : evo ()->getConfig ('friendly_url_suffix ' , '' );
324- $ url = app ('url ' )->route ($ name , $ parameters , $ absolute ).$ suffix ;
327+ static $ mgrRoutes = null ;
328+
329+ if ($ mgrRoutes === null ) {
330+ $ mgrRoutes = [];
331+ foreach (app ('router ' )->getRoutes () as $ route ) {
332+ if ($ route ->getName () && in_array ('mgr ' , $ route ->gatherMiddleware ())) {
333+ $ mgrRoutes [] = $ route ->getName ();
334+ }
335+ }
336+ }
337+
338+ $ suffix = (in_array ($ name , $ mgrRoutes ) || count ($ parameters )) ? '' : evo ()->getConfig ('friendly_url_suffix ' , '' );
339+ $ url = app ('url ' )->route ($ name , $ parameters , $ absolute ) . $ suffix ;
340+
325341 if (evo ()->getConfig ('server_protocol ' , 'https ' ) == 'https ' ) {
326342 $ url = str_ireplace ('http:// ' , 'https:// ' , $ url );
327343 }
328344 return $ url ;
329345 }
330346}
331347
332- if (! function_exists ('session ' )) {
348+ if (!function_exists ('session ' )) {
333349 /**
334350 * Get / set the specified session value.
335351 *
@@ -353,7 +369,7 @@ function session($key = null, $default = null)
353369 }
354370}
355371
356- if (! function_exists ('today ' )) {
372+ if (!function_exists ('today ' )) {
357373 /**
358374 * Create a new Carbon instance for the current date.
359375 *
@@ -366,7 +382,7 @@ function today($tz = null)
366382 }
367383}
368384
369- if (! function_exists ('trans ' )) {
385+ if (!function_exists ('trans ' )) {
370386 /**
371387 * Translate the given message.
372388 *
@@ -386,7 +402,7 @@ function trans($key = null, $replace = [], $locale = null)
386402}
387403
388404
389- if (! function_exists ('trans_choice ' )) {
405+ if (!function_exists ('trans_choice ' )) {
390406 /**
391407 * Translates the given message based on a count.
392408 *
@@ -402,7 +418,7 @@ function trans_choice($key, $number, array $replace = [], $locale = null)
402418 }
403419}
404420
405- if (! function_exists ('__ ' )) {
421+ if (!function_exists ('__ ' )) {
406422 /**
407423 * Translate the given message.
408424 *
@@ -422,7 +438,7 @@ function __($key = null, $replace = [], $locale = null)
422438}
423439
424440
425- if (! function_exists ('validator ' )) {
441+ if (!function_exists ('validator ' )) {
426442 /**
427443 * Create a new Validator instance.
428444 *
@@ -444,7 +460,7 @@ function validator(array $data = [], array $rules = [], array $messages = [], ar
444460 }
445461}
446462
447- if (! function_exists ('database_path ' )) {
463+ if (!function_exists ('database_path ' )) {
448464 /**
449465 * Get the database path.
450466 *
@@ -457,7 +473,7 @@ function database_path($path = '')
457473 }
458474}
459475
460- if (! function_exists ('url ' )) {
476+ if (!function_exists ('url ' )) {
461477 /**
462478 * Create an URL for the given document identifier. The url prefix and postfix are used, when “friendly_url” is active.
463479 *
@@ -473,7 +489,7 @@ function url(int $id, string $alias = '', string $args = '', string $scheme = ''
473489 }
474490}
475491
476- if (! function_exists ('cache ' )) {
492+ if (!function_exists ('cache ' )) {
477493 /**
478494 * Get / set the specified cache value.
479495 *
@@ -506,7 +522,7 @@ function cache()
506522 }
507523}
508524
509- if (! function_exists ('view ' )) {
525+ if (!function_exists ('view ' )) {
510526 /**
511527 * Get the evaluated view contents for the given view.
512528 *
0 commit comments