Minify_Controller_Groups

Controller class for serving predetermined groups of minimized sets, selected by PATH_INFO.

Defined (1)

The class is defined in the following location(s).

/lib/Minify/Minify/Controller/Groups.php  
  1. class Minify_Controller_Groups extends Minify_Controller_Base { 
  2.  
  3. /** 
  4. * Set up groups of files as sources 
  5. *  
  6. * @param array $options controller and Minify options 
  7. * 'groups': (required) array mapping PATH_INFO strings to arrays 
  8. * of complete file paths. @see Minify_Controller_Groups 
  9. * @return array Minify options 
  10. */ 
  11. public function setupSources($options) { 
  12. // strip controller options 
  13. $groups = $options['groups']; 
  14. unset($options['groups']); 
  15.  
  16. // mod_fcgid places PATH_INFO in ORIG_PATH_INFO 
  17. $pi = isset($_SERVER['ORIG_PATH_INFO']) 
  18. ? substr($_SERVER['ORIG_PATH_INFO'], 1)  
  19. : (isset($_SERVER['PATH_INFO']) 
  20. ? substr($_SERVER['PATH_INFO'], 1)  
  21. : false 
  22. ); 
  23. if (false === $pi || ! isset($groups[$pi])) { 
  24. // no PATH_INFO or not a valid group 
  25. $this->log("Missing PATH_INFO or no group set for \"$pi\""); 
  26. return $options; 
  27. $sources = array(); 
  28.  
  29. $files = $groups[$pi]; 
  30. // if $files is a single object, casting will break it 
  31. if (is_object($files)) { 
  32. $files = array($files); 
  33. } elseif (! is_array($files)) { 
  34. $files = (array)$files; 
  35. foreach ($files as $file) { 
  36. if ($file instanceof Minify_Source) { 
  37. $sources[] = $file; 
  38. continue; 
  39. if (0 === strpos($file, '//')) { 
  40. $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1); 
  41. $realPath = realpath($file); 
  42. if (is_file($realPath)) { 
  43. $sources[] = new Minify_Source(array( 
  44. 'filepath' => $realPath 
  45. ));  
  46. } else { 
  47. $this->log("The path \"{$file}\" could not be found (or was not a file)"); 
  48. return $options; 
  49. if ($sources) { 
  50. $this->sources = $sources; 
  51. return $options;