Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
2f999397
Commit
2f999397
authored
Jul 07, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trim comment bloat from URL class.
parent
a2406c01
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
30 deletions
+6
-30
url.php
system/url.php
+6
-30
No files found.
system/url.php
View file @
2f999397
...
...
@@ -12,9 +12,6 @@ class URL {
*/
public
static
function
to
(
$url
=
''
,
$https
=
false
,
$asset
=
false
)
{
// ----------------------------------------------------
// Return the URL unchanged if it is already formed.
// ----------------------------------------------------
if
(
strpos
(
$url
,
'://'
)
!==
false
)
{
return
$url
;
...
...
@@ -22,19 +19,13 @@ class URL {
$base
=
Config
::
get
(
'application.url'
);
// ----------------------------------------------------
// Assets live in the public directory, so we don't
// want to append the index file to the URL if the
// URL is to an asset.
// ----------------------------------------------------
// Assets live in the public directory, so we only want to append
// the index file if the URL is to an asset.
if
(
!
$asset
)
{
$base
.=
'/'
.
Config
::
get
(
'application.index'
);
}
// ----------------------------------------------------
// Does the URL need an HTTPS protocol?
// ----------------------------------------------------
if
(
strpos
(
$base
,
'http://'
)
===
0
and
$https
)
{
$base
=
'https://'
.
substr
(
$base
,
7
);
...
...
@@ -78,18 +69,13 @@ class URL {
{
if
(
!
is_null
(
$route
=
Route\Finder
::
find
(
$name
)))
{
// ----------------------------------------------------
// Get the first URI assigned to the route.
// ----------------------------------------------------
$uris
=
explode
(
', '
,
key
(
$route
));
$uri
=
substr
(
$uris
[
0
],
strpos
(
$uris
[
0
],
'/'
));
// ----------------------------------------------------
// Replace any parameters in the URI. This allows
// the dynamic creation of URLs that contain parameter
// wildcards.
// ----------------------------------------------------
// Replace any parameters in the URI. This allows the dynamic creation of URLs
// that contain parameter wildcards.
foreach
(
$parameters
as
$parameter
)
{
$uri
=
preg_replace
(
'/\(.+?\)/'
,
$parameter
,
$uri
,
1
);
...
...
@@ -122,16 +108,10 @@ class URL {
*/
public
static
function
slug
(
$title
,
$separator
=
'-'
)
{
// ----------------------------------------------------
// Remove all characters that are not the separator,
// letters, numbers, or whitespace.
// ----------------------------------------------------
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title
=
preg_replace
(
'![^'
.
preg_quote
(
$separator
)
.
'\pL\pN\s]+!u'
,
''
,
Str
::
lower
(
$title
));
// ----------------------------------------------------
// Replace all separator characters and whitespace by
// a single separator
// ----------------------------------------------------
// Replace all separator characters and whitespace by a single separator
$title
=
preg_replace
(
'!['
.
preg_quote
(
$separator
)
.
'\s]+!u'
,
$separator
,
$title
);
return
trim
(
$title
,
$separator
);
...
...
@@ -144,17 +124,13 @@ class URL {
{
$parameters
=
(
isset
(
$parameters
[
0
]))
?
$parameters
[
0
]
:
array
();
// ----------------------------------------------------
// Dynamically create a secure route URL.
// ----------------------------------------------------
if
(
strpos
(
$method
,
'to_secure_'
)
===
0
)
{
return
static
::
to_route
(
substr
(
$method
,
10
),
$parameters
,
true
);
}
// ----------------------------------------------------
// Dynamically create a route URL.
// ----------------------------------------------------
if
(
strpos
(
$method
,
'to_'
)
===
0
)
{
return
static
::
to_route
(
substr
(
$method
,
3
),
$parameters
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment