/** * The remove Team action of the Clan. * @param int $id The ID of the Clan which Teams are to be removed. * @since 0.0.1-dev */ public function teamRemove($id) { //load the needed Session. $this->needSession(); //check if the ID of the Clan is available. if (is_numeric($id) && $id > 0) { //get the Teams which are to be removed. $options = ['flags' => FILTER_REQUIRE_ARRAY | FILTER_NULL_ON_FAILURE]; $teams = filter_input(INPUT_POST, 'teams', FILTER_DEFAULT, $options); //check if a Team was found. if ($teams !== false && count($teams) > 0) { $clans = ClanRepository::build()->findByID($id); //check if the Clan could be found. if (count($clans) === 1) { $clan = $clans[0]; //find all Teams which should be assigend with the Clan. $teams = TeamRepository::build()->findByID($teams); //check if Teams are available. if (count($teams) > 0) { $clanTeamTableMapper = ClanTeamTableMapper::build(); //run through all Teams to assign with the Clan. foreach ($teams as $team) { $clanTeamTableMapper->delete($clan, $team); } } //redirect to the edit view of the Clan. $this->redirect(URL . 'clan/edit/' . $clan->id); } } } //redirect to the overview of the Clan. $this->redirect(URL . 'clan'); }