当前位置: 首页>>代码示例>>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;未经允许,请勿转载。