Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1336173
URISpec.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
URISpec.php
View Options
<?php
namespace
RESTful
;
class
URISpec
{
public
$collection_uri
=
null
,
$name
,
$idNames
;
public
function
__construct
(
$name
,
$idNames
,
$root
=
null
)
{
$this
->
name
=
$name
;
if
(!
is_array
(
$idNames
))
{
$idNames
=
array
(
$idNames
);
}
$this
->
idNames
=
$idNames
;
if
(
$root
!=
null
)
{
if
(
$root
==
''
||
substr
(
$root
,
-
1
)
==
'/'
)
{
$this
->
collection_uri
=
$root
.
$name
;
}
else
{
$this
->
collection_uri
=
$root
.
'/'
.
$name
;
}
}
}
public
function
match
(
$uri
)
{
$parts
=
explode
(
'/'
,
rtrim
(
$uri
,
"/"
));
// collection
if
(
$parts
[
count
(
$parts
)
-
1
]
==
$this
->
name
)
{
return
array
(
'collection'
=>
true
,
);
}
// non-member
if
(
count
(
$parts
)
<
count
(
$this
->
idNames
)
+
1
||
$parts
[
count
(
$parts
)
-
1
-
count
(
$this
->
idNames
)]
!=
$this
->
name
)
{
return
null
;
}
// member
$ids
=
array_combine
(
$this
->
idNames
,
array_slice
(
$parts
,
-
count
(
$this
->
idNames
))
);
$result
=
array
(
'collection'
=>
false
,
'ids'
=>
$ids
,
);
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jul 6, 7:36 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
316102
Default Alt Text
URISpec.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment