コード例 #1
0
 /**
  * Main method to handle the user submitted word. Word is evaluated for correctness first.
  * After that it is added to the database and a proper message is displayed.
  * @return void
  */
 public function doSubmit()
 {
     $wordToBeAdded = $this->view->getWordToSubmit();
     if ($this->view->didUserPressSubmit()) {
         try {
             if ($this->checkWord($wordToBeAdded)) {
                 $this->wordList->add($wordToBeAdded);
                 $this->view->setMessageSuccess();
             }
         } catch (WordInvalidCharException $wie) {
             $this->view->setMessageInvalidInput();
         } catch (WordSizeException $wse) {
             $this->view->setMessageInvalidSize();
         } catch (WordExistsException $wee) {
             $this->view->setMessageDublicate();
         }
     }
 }
コード例 #2
0
 public function setMessageDublicate()
 {
     self::$messageField = "Word already exists in database.";
 }