當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model::getMessages方法代碼示例

本文整理匯總了PHP中Phalcon\Mvc\Model::getMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::getMessages方法的具體用法?PHP Model::getMessages怎麽用?PHP Model::getMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phalcon\Mvc\Model的用法示例。


在下文中一共展示了Model::getMessages方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getErrorMessages

 /**
  * Modelのエラーメッセージを取得
  * @return array
  */
 public function getErrorMessages()
 {
     foreach ($this->model->getMessages() as $msgs) {
         $errMsgs[] = $msgs->getMessage();
     }
     return $errMsgs;
 }
開發者ID:muramoya,項目名稱:kotori,代碼行數:11,代碼來源:BaseResources.php

示例2: showModelErrors

 public function showModelErrors(Model $model, Form $form)
 {
     foreach ($model->getMessages() as $message) {
         $fieldName = $message->getField();
         $form->addModelError($fieldName, $message->getMessage());
     }
 }
開發者ID:adiachenko,項目名稱:phstart,代碼行數:7,代碼來源:ControllerBase.php

示例3: getMessages

 /**
  * Replace/translate default messages generated by the ORM.
  *
  * @return array
  */
 public function getMessages()
 {
     foreach (parent::getMessages() as $message) {
         switch ($message->getType()) {
             case 'PresenceOf':
                 $message->setMessage('The field ' . $message->getField() . ' is required');
                 break;
             case 'Uniqueness':
                 $message->setMessage('The field ' . $message->getField() . ' must be unique');
                 break;
             case 'Email':
                 $message->setMessage('The field ' . $message->getField() . ' must contain a valid email');
                 break;
             case 'Url':
                 $message->setMessage('The field ' . $message->getField() . ' must contain a valid url');
                 break;
             case 'InclusionIn':
                 $message->setMessage('The field ' . $message->getField() . ' must contain a value in [' . implode(',', $message->getDomain()) . ']');
                 break;
             case 'DateValidator':
                 $message->setMessage('The field ' . $message->getField() . ' must contain a valid date.');
                 break;
             case 'TimestampValidator':
                 $message->setMessage('The field ' . $message->getField() . ' must contain a valid timestamps.');
                 break;
         }
     }
     return parent::getMessages();
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:34,代碼來源:BaseModel.php

示例4: createModelErrorMessages

 /**
  * Recebe um model e une as excessões para retornar em texto
  * 
  * @param \Phalcon\Mvc\Model $model
  * @return string
  */
 public static function createModelErrorMessages(\Phalcon\Mvc\Model $model)
 {
     $excepts = [];
     foreach ($model->getMessages() as $message) {
         $excepts[] = $message;
     }
     return implode("\n", $excepts);
 }
開發者ID:anderson-slompo,項目名稱:wsGerProj,代碼行數:14,代碼來源:PostResponse.php

示例5: getMessages

 /**
  * @param bool $bAsString
  * @return \Phalcon\Mvc\Model\MessageInterface[]|string
  */
 public function getMessages($bAsString = false)
 {
     if (!$bAsString) {
         return parent::getMessages();
     } else {
         return implode(', ', parent::getMessages());
     }
 }
開發者ID:kp-favorite,項目名稱:bitfalls_utils,代碼行數:12,代碼來源:Model.php

示例6: databaseErrorLog

 /**
  * 數據庫操作異常
  * @param \Phalcon\Mvc\Model $model
  * @return bool
  */
 public function databaseErrorLog($model)
 {
     $error = '';
     foreach ($model->getMessages() as $msg) {
         $error .= $msg . ',';
     }
     $this->di->get('logger')->error('數據庫異常, GET:' . json_encode($_GET) . ', POST:' . json_encode($_POST) . ', error: ' . $error);
     return false;
 }
開發者ID:fu-tao,項目名稱:meelier_c,代碼行數:14,代碼來源:BaseController.php

示例7: logDatabaseError

 /**
  * 數據庫操作異常
  * @param \Phalcon\Mvc\Model $model
  */
 public function logDatabaseError($model)
 {
     if ($this->di->offsetExists('logger') == false) {
         return;
     }
     $error = '';
     foreach ($model->getMessages() as $msg) {
         $error .= $msg . ',';
     }
     $this->di->get('logger')->error('數據庫異常, GET:' . json_encode($_GET) . ', POST: ' . json_encode($_POST) . ', error: ' . $error);
 }
開發者ID:fu-tao,項目名稱:meelier_c,代碼行數:15,代碼來源:Component.php

示例8: delete

 public function delete()
 {
     $response = array();
     if (parent::delete() == false) {
         foreach (parent::getMessages() as $message) {
             $response['errors'][] = (string) $message;
         }
     } else {
         $response['msg'] = 'ok';
     }
     return $response;
 }
開發者ID:Archcry,項目名稱:PhalconApiBase,代碼行數:12,代碼來源:Model.php

示例9: getMessages

 public function getMessages($filter = null)
 {
     foreach (parent::getMessages() as $message) {
         switch ($message->getType()) {
             case 'Email':
                 $message->setMessage('Указан не действительный E-mail.');
                 break;
             case 'PresenceOf':
                 $message->setMessage('Поле "' . $this->getLabel($message->getField()) . '" должно быть заполнено');
                 break;
         }
     }
     return parent::getMessages();
 }
開發者ID:atnartur,項目名稱:SimpleBannerRotator,代碼行數:14,代碼來源:ModelBase.php

示例10: getMessages

 /**
  * Override default interface
  */
 public function getMessages($filter = null)
 {
     $messages = array();
     foreach (parent::getMessages() as $message) {
         switch ($message->getType()) {
             case 'InvalidCreateAttempt':
                 $messages[] = 'The record cannot be created because it already exists';
                 break;
             case 'InvalidUpdateAttempt':
                 $messages[] = 'The record cannot be updated because it already exists';
                 break;
             case 'PresenceOf':
                 $messages[] = 'The field ' . $message->getField() . ' is mandatory';
                 break;
         }
     }
     return $messages;
 }
開發者ID:hacktm15,項目名稱:CityBox,代碼行數:21,代碼來源:ModelBase.php

示例11: getMessages

 /**
  * 把信息格式化成我們需要的
  *
  * @param null $filter
  * @return array|\Phalcon\Mvc\MessageInterface[]
  */
 public function getMessages($filter = null)
 {
     $messages = parent::getMessages($filter);
     if (empty($messages)) {
         return parent::getMessages($filter);
     }
     $arrayMessages['errors'] = array();
     foreach ($messages as $message) {
         switch ($message->getType()) {
             case 'PresenceOf':
                 $arrayMessages['errors'][] = array('code' => BaseController::FIELD_REQUIRED, 'field' => $message->getField(), 'message' => $message->getMessage());
                 break;
             case 'Inclusion':
                 $arrayMessages['errors'][] = array('code' => BaseController::PARAMS_INVALID, 'field' => $message->getField(), 'message' => $message->getMessage());
                 break;
         }
     }
     return $arrayMessages;
 }
開發者ID:yqh2002,項目名稱:Phalcon-RESTful-Server,代碼行數:25,代碼來源:BaseModel.php

示例12: getMessages

 public function getMessages($filter = NULL)
 {
     $messages = array();
     foreach (parent::getMessages() as $message) {
         switch ($message->getType()) {
             case 'PresenceOf':
                 $messages[] = 'El campo ' . $message->getField() . ' es obligatorio.';
                 break;
             case 'Email':
                 $messages[] = 'El campo ' . $message->getField() . ' no tiene un formato válido.';
                 break;
             case 'Unique':
                 $messages[] = 'El campo ' . $message->getField() . ' ya está en uso.';
                 break;
             case 'TooShort':
                 $messages[] = 'El campo ' . $message->getField() . ' es demasiado corto(min 2 chars).';
                 break;
             case 'TooLong':
                 $messages[] = 'El campo ' . $message->getField() . ' es demasiado largo(max 30 chars).';
                 break;
         }
     }
     return $messages;
 }
開發者ID:bodypheo,項目名稱:Proyecto-Fin-de-Carrera,代碼行數:24,代碼來源:Usuario.php

示例13: getMessages

 public function getMessages()
 {
     $messages = array();
     $txtmessage = "";
     foreach (parent::getMessages() as $message) {
         switch ($message->getType()) {
             case 'PresenceOf':
                 switch ($message->getField()) {
                     case 'name':
                         $txtmessage = $this->di->get('translate')->_('event.name.required');
                         break;
                     case 'start_date':
                         $txtmessage = $this->di->get('translate')->_('event.start_date.required');
                         break;
                     case 'finish_date':
                         $txtmessage = $this->di->get('translate')->_('event.finish_date.required');
                         break;
                 }
                 $messages[] = $txtmessage;
                 break;
             case 'Unique':
                 if (is_array($message->getField())) {
                     $field = implode("-", $message->getField());
                 } else {
                     $field = $message->getField();
                 }
                 switch ($field) {
                     case 'name':
                         $txtmessage = $this->di->get('translate')->_('event.exist');
                         break;
                 }
                 $messages[] = $txtmessage;
                 break;
             case 'ConstraintViolation':
                 $txtmessage = $this->di->get('translate')->_('event.constraintviolation');
                 $messages[] = $txtmessage;
                 break;
             case 'Invalid_Dates':
                 $txtmessage = $this->di->get('translate')->_('event.invalid_dates');
                 $messages[] = $txtmessage;
                 break;
         }
     }
     return $messages;
 }
開發者ID:andresfranco,項目名稱:Phalcontest,代碼行數:45,代碼來源:Event.php

示例14: getMessages

 public function getMessages($filter = null)
 {
     $messages = parent::getMessages($filter);
     return is_array($messages) ? $messages : [];
 }
開發者ID:rub3nlh,項目名稱:webird,代碼行數:5,代碼來源:Model.php

示例15: onRemoveFailed

 protected function onRemoveFailed(Model $item)
 {
     throw new Exception(ErrorCodes::DATA_FAILED, 'Unable to remove item', ['messages' => $this->_getMessages($item->getMessages()), 'item' => $item->toArray()]);
 }
開發者ID:olivierandriessen,項目名稱:phalcon-rest,代碼行數:4,代碼來源:CrudResourceController.php


注:本文中的Phalcon\Mvc\Model::getMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。