[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Defines the location of static resources on disk. 5 */ 6 abstract class CelerityResourcesOnDisk extends CelerityPhysicalResources { 7 8 abstract public function getPathToResources(); 9 10 private function getPathToResource($name) { 11 return $this->getPathToResources().DIRECTORY_SEPARATOR.$name; 12 } 13 14 public function getResourceData($name) { 15 return Filesystem::readFile($this->getPathToResource($name)); 16 } 17 18 public function findBinaryResources() { 19 return $this->findResourcesWithSuffixes($this->getBinaryFileSuffixes()); 20 } 21 22 public function findTextResources() { 23 return $this->findResourcesWithSuffixes($this->getTextFileSuffixes()); 24 } 25 26 public function getResourceModifiedTime($name) { 27 return (int)filemtime($this->getPathToResource($name)); 28 } 29 30 protected function getBinaryFileSuffixes() { 31 return array( 32 'png', 33 'jpg', 34 'gif', 35 'swf', 36 'woff', 37 'ttf', 38 'eot', 39 ); 40 } 41 42 protected function getTextFileSuffixes() { 43 return array( 44 'js', 45 'css', 46 ); 47 } 48 49 private function findResourcesWithSuffixes(array $suffixes) { 50 $root = $this->getPathToResources(); 51 52 $finder = id(new FileFinder($root)) 53 ->withType('f') 54 ->withFollowSymlinks(true) 55 ->setGenerateChecksums(true); 56 57 foreach ($suffixes as $suffix) { 58 $finder->withSuffix($suffix); 59 } 60 61 $raw_files = $finder->find(); 62 63 $results = array(); 64 foreach ($raw_files as $path => $hash) { 65 $readable = Filesystem::readablePath($path, $root); 66 $results[$readable] = $hash; 67 } 68 69 return $results; 70 } 71 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |