Esempio n. 1
0
 /**
  * Deletes sagas and chapters will not be any more in database.
  * Used in /anime/actions/executeRefreshAnime
  *
  * @param Anime $anime
  * @param Array $current_sagas ex: [2, 5]
  * @param Array $current_chapters ex: [23, 54]
  */
 public static function deleteSagasAndChapters($anime, $current_sagas, $current_chapters)
 {
     foreach ($anime['Sagas'] as $saga) {
         if (!in_array($saga['id'], $current_sagas)) {
             $anime->unlink('Sagas', $saga['id']);
             $saga->delete();
         } else {
             foreach ($saga['Chapters'] as $chapter) {
                 if (!in_array($chapter['id'], $current_chapters)) {
                     $saga->unlink('Chapters', $chapter['id']);
                     $chapter->delete();
                 }
             }
         }
     }
 }