Path: blob/master/src/applications/celerity/resources/CelerityResourcesOnDisk.php
12256 views
<?php12/**3* Defines the location of static resources on disk.4*/5abstract class CelerityResourcesOnDisk extends CelerityPhysicalResources {67abstract public function getPathToResources();89private function getPathToResource($name) {10return $this->getPathToResources().DIRECTORY_SEPARATOR.$name;11}1213public function getResourceData($name) {14return Filesystem::readFile($this->getPathToResource($name));15}1617public function findBinaryResources() {18return $this->findResourcesWithSuffixes($this->getBinaryFileSuffixes());19}2021public function findTextResources() {22return $this->findResourcesWithSuffixes($this->getTextFileSuffixes());23}2425public function getResourceModifiedTime($name) {26return (int)filemtime($this->getPathToResource($name));27}2829protected function getBinaryFileSuffixes() {30return array(31'png',32'jpg',33'gif',34'swf',35'svg',36'woff',37'woff2',38'ttf',39'eot',40'mp3',41'ico',42);43}4445protected function getTextFileSuffixes() {46return array(47'js',48'css',49);50}5152private function findResourcesWithSuffixes(array $suffixes) {53$root = $this->getPathToResources();5455$finder = id(new FileFinder($root))56->withType('f')57->withFollowSymlinks(true)58->setGenerateChecksums(true);5960foreach ($suffixes as $suffix) {61$finder->withSuffix($suffix);62}6364$raw_files = $finder->find();6566$results = array();67foreach ($raw_files as $path => $hash) {68$readable = Filesystem::readablePath($path, $root);69$results[$readable] = $hash;70}7172return $results;73}7475}767778