/**
  * Get the last modified timestamp for the files in this collection, will
  * return 0 if there are no files or all failed to get last modified timestamp
  *
  * @return  int
  */
 public function getLastModifiedTimestamp()
 {
     $newestTimestamp = 0;
     foreach ($this->getFiles() as $file) {
         $timestamp = sfCombineUtility::getModifiedTimestamp($file, array($this, 'getAssetPath'));
         if ($timestamp > $newestTimestamp) {
             $newestTimestamp = $timestamp;
         }
     }
     return $newestTimestamp;
 }
 /**
  * Group the various assets together into an array. Determines which files
  * can be grouped together and the ordering.
  *
  * @param   array $assets           An array of file names
  * @param   bool  $combine          (Optional) Whether to allow combining or
  *                                  not. Default true.
  * @param   mixed $groupsUse        (Optional) A string or array of groups to
  *                                  include or exclude. Null for this to be
  *                                  ignored. Default null.
  * @param   int   $groupsUseType    (Optional) The type of grouping either
  *                                  sfCombineManager::GROUP_INCLUDE or
  *                                  sfCombineManager::GROUP_EXCLUDE.
  *                                  These dictate whether the group(s) in
  *                                  the previous argument should be marked
  *                                  as used or every group marked as used.
  *                                  Default sfCombineManager::GROUP_INCLUDE
  * @param   bool  $onlyUnusedGroups (Optional) Only use unused groups. Default
  *                                  true.
  * @param   bool  $markGroupsUsed   (Optional) Mark the groups that are used
  *                                  as used. Default true.
  * @return  array An array of grouped files ready for combining. Array is in
  *                the form of files => array of file names, options => array
  *                of options for that grouping, combinable => bool (whether
  *                to put the file through sfCombine (otherwise links
  *                outside of sfCombine))
  */
 public function getAssetsByGroup($assets, $combine = true, $groupsUse = null, $groupsUseType = self::GROUP_INCLUDE, $onlyUnusedGroups = true, $markGroupsUsed = true, $assetPathMethod = null)
 {
     $groupData = $this->getGroups();
     $notCombined = $combined = array();
     foreach ($assets as $file => $options) {
         // check asset still needs to be added
         if (!array_key_exists($file, $assets)) {
             continue;
         }
         // get the group this file is in
         $group = array_key_exists($file, $groupData) ? $groupData[$file] : '';
         if ($groupsUse !== null) {
             if (is_string($groupsUse)) {
                 $groupsUse = array($groupsUse);
             }
             if ($groupsUseType === self::GROUP_INCLUDE) {
                 // only allow specific groups
                 if (!in_array($group, $groupsUse)) {
                     // don't include this group
                     continue;
                 }
             } else {
                 if ($groupsUseType === self::GROUP_EXCLUDE) {
                     // only exclude specific groups
                     if (in_array($group, $groupsUse)) {
                         // don't include this group
                         continue;
                     }
                 }
             }
         }
         // don't output a used group
         if ($onlyUnusedGroups && in_array($group, $this->getUsedGroups())) {
             continue;
         }
         $timestampConfig = sfConfig::get('app_sfCombinePlugin_timestamp', array());
         $timestampEnabled = isset($timestampConfig['enabled']) && $timestampConfig['enabled'];
         if (!$combine || !sfCombineUtility::combinableFile($file, $this->getSkips())) {
             if ($timestampEnabled) {
                 $timestamp = sfCombineUtility::getModifiedTimestamp($file, $assetPathMethod);
             } else {
                 $timestamp = 0;
             }
             // file not combinable
             $notCombined[] = array('files' => $file, 'options' => $options, 'combinable' => false, 'timestamp' => $timestamp);
             unset($assets[$file]);
         } else {
             // get the group this file is in
             $group = array_key_exists($file, $groupData) ? $groupData[$file] : '';
             $combinedFiles = array($file);
             // get timestamp
             if ($timestampEnabled) {
                 $timestamp = sfCombineUtility::getModifiedTimestamp($file, $assetPathMethod);
             } else {
                 $timestamp = 0;
             }
             unset($assets[$file]);
             foreach ($assets as $groupedFile => $groupedOptions) {
                 if (!sfCombineUtility::combinableFile($groupedFile, $this->getSkips()) || $options != $groupedOptions) {
                     continue;
                 }
                 $groupedFileGroup = array_key_exists($groupedFile, $groupData) ? $groupData[$groupedFile] : '';
                 // add this file to this combine
                 if ($group == $groupedFileGroup) {
                     if ($timestampEnabled) {
                         $groupedTimestamp = sfCombineUtility::getModifiedTimestamp($groupedFile, $assetPathMethod);
                         if ($groupedTimestamp > $timestamp) {
                             $timestamp = $groupedTimestamp;
                         }
                     }
                     $combinedFiles[] = $groupedFile;
                     unset($assets[$groupedFile]);
                 }
             }
             $combined[] = array('files' => $combinedFiles, 'options' => $options, 'combinable' => true, 'timestamp' => $timestamp);
         }
     }
     if ($markGroupsUsed) {
         $this->updateUsedGroups($groupsUse, $groupsUseType);
     }
     return array_merge($notCombined, $combined);
 }