Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93596850
CelerityResourcesOnDisk.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 30, 01:11
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 01:11 (2 d)
Engine
blob
Format
Raw Data
Handle
22673085
Attached To
rPH Phabricator
CelerityResourcesOnDisk.php
View Options
<?php
/**
* Defines the location of static resources on disk.
*/
abstract
class
CelerityResourcesOnDisk
extends
CelerityResources
{
abstract
public
function
getPathToResources
();
private
function
getPathToResource
(
$name
)
{
return
$this
->
getPathToResources
().
DIRECTORY_SEPARATOR
.
$name
;
}
public
function
getResourceData
(
$name
)
{
return
Filesystem
::
readFile
(
$this
->
getPathToResource
(
$name
));
}
public
function
findBinaryResources
()
{
return
$this
->
findResourcesWithSuffixes
(
$this
->
getBinaryFileSuffixes
());
}
public
function
findTextResources
()
{
return
$this
->
findResourcesWithSuffixes
(
$this
->
getTextFileSuffixes
());
}
public
function
getResourceModifiedTime
(
$name
)
{
return
(
int
)
filemtime
(
$this
->
getPathToResource
(
$name
));
}
protected
function
getBinaryFileSuffixes
()
{
return
array
(
'png'
,
'jpg'
,
'gif'
,
'swf'
,
);
}
protected
function
getTextFileSuffixes
()
{
return
array
(
'js'
,
'css'
,
);
}
private
function
findResourcesWithSuffixes
(
array
$suffixes
)
{
$root
=
$this
->
getPathToResources
();
$finder
=
id
(
new
FileFinder
(
$root
))
->
withType
(
'f'
)
->
withFollowSymlinks
(
true
)
->
setGenerateChecksums
(
true
);
foreach
(
$suffixes
as
$suffix
)
{
$finder
->
withSuffix
(
$suffix
);
}
$raw_files
=
$finder
->
find
();
$results
=
array
();
foreach
(
$raw_files
as
$path
=>
$hash
)
{
$readable
=
Filesystem
::
readablePath
(
$path
,
$root
);
$results
[
$readable
]
=
$hash
;
}
return
$results
;
}
}
Event Timeline
Log In to Comment