File modules/cms/action/language/LanguageRemoveAction.class.php

Last commit: Tue Feb 14 21:48:16 2023 +0100	Jan Dankert	Fix: Be sure that there are at least 1 language and 1 model.
1 <?php 2 namespace cms\action\language; 3 use cms\action\LanguageAction; 4 use cms\action\Method; 5 use cms\model\Project; 6 use language\Messages; 7 use util\exception\ClientException; 8 use util\exception\UIException; 9 use util\exception\ValidationException; 10 11 12 class LanguageRemoveAction extends LanguageAction implements Method { 13 14 public function view() { 15 16 17 $project = Project::create( $this->language->projectid ); 18 19 // There must be at least 1 language 20 if ( count( $project->getLanguageIds() ) <= 1 ) 21 throw new ClientException("there must be at least 1 language."); 22 23 $this->setTemplateVar('name' ,$this->language->name ); 24 } 25 26 27 public function post() { 28 29 if ( $this->request->getRequiredNumber('confirm') ) { 30 31 $project = Project::create( $this->language->projectid ); 32 33 // There must be at least 1 language 34 if ( count( $project->getLanguageIds() ) > 1 ) { 35 36 $this->language->delete(); 37 38 $this->addNoticeFor( $this->language, Messages::DELETED ); 39 } 40 else { 41 $this->addErrorFor( $this->language, Messages::NOTHING_DONE ); 42 } 43 } 44 } 45 }
Download modules/cms/action/language/LanguageRemoveAction.class.php
History Tue, 14 Feb 2023 21:48:16 +0100 Jan Dankert Fix: Be sure that there are at least 1 language and 1 model. Mon, 6 Dec 2021 22:33:10 +0100 dankert Some fixes for deleting objects. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.