Beispiel #1
0
 /**
  * @param string $directory Directory with patches
  * @param bool   $only_new  True to list not applied, false to list all
  * @param bool   $legacy    True when patch is located in /tools directory.
  *                          Required to calculate proper patch id. Should not
  *                          be used, because it's for compatibility.
  *
  * @return Patch[]
  */
 private static function _list_patches($directory, $only_new = false, $legacy = false)
 {
     if (!is_dir($directory)) {
         return array();
     }
     $patches_db = new PatchesDB();
     $patches = array();
     $directory = rtrim($directory, '/\\') . '/';
     $d = dir($directory);
     while (false !== ($entry = $d->read())) {
         $entry = $directory . $entry;
         if (self::_is_patch_file($entry)) {
             $x = new Patch($entry, $patches_db);
             $x->set_legacy($legacy);
             if ($only_new) {
                 if (!$x->was_applied()) {
                     $patches[] = $x;
                 }
             } else {
                 $patches[] = $x;
             }
         }
     }
     $d->close();
     self::_sort_patches_by_date($patches);
     return $patches;
 }