当前位置: 首页>>代码示例>>PHP>>正文


PHP Tools::atkTriggerError方法代码示例

本文整理汇总了PHP中Sintattica\Atk\Core\Tools::atkTriggerError方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::atkTriggerError方法的具体用法?PHP Tools::atkTriggerError怎么用?PHP Tools::atkTriggerError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sintattica\Atk\Core\Tools的用法示例。


在下文中一共展示了Tools::atkTriggerError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateUniqueFieldSets

 /**
  * Check unique field combinations.
  * The function is called by the validate() method automatically. It is
  * not necessary to call this manually in a validation process.
  * Errors that are found are stored in the $record parameter.
  *
  * @param array $record The record to validate
  */
 public function validateUniqueFieldSets(&$record)
 {
     $db = $this->m_nodeObj->getDb();
     foreach ($this->m_nodeObj->m_uniqueFieldSets as $uniqueFieldSet) {
         $query = $db->createQuery();
         $query->addField('*');
         $query->addTable($this->m_nodeObj->m_table);
         $attribs = [];
         foreach ($uniqueFieldSet as $field) {
             $attrib = $this->m_nodeObj->m_attribList[$field];
             if ($attrib) {
                 $attribs[] = $attrib;
                 if (method_exists($attrib, 'createDestination') && isset($attrib->m_refKey) && is_array($attrib->m_refKey) && count($attrib->m_refKey) > 1) {
                     $attrib->createDestination();
                     foreach ($attrib->m_refKey as $refkey) {
                         $query->addCondition($query->quoteField($refkey) . " = '" . $db->escapeSQL($record[$attrib->fieldName()][$refkey]) . "'");
                     }
                 } else {
                     if (!$attrib->isNotNullInDb() && $attrib->isEmpty($record)) {
                         $query->addCondition($query->quoteField($field) . ' IS NULL');
                     } else {
                         $query->addCondition($query->quoteField($field) . " = '" . $attrib->value2db($record) . "'");
                     }
                 }
             } else {
                 Tools::atkerror("Field {$field} is mentioned in uniquefieldset but does not exist in " . $this->m_nodeObj->atkNodeUri());
             }
         }
         if ($this->m_mode != 'add') {
             $query->addCondition('NOT (' . $this->m_nodeObj->primaryKey($record) . ')');
         }
         if (count($db->getRows($query->buildSelect())) > 0) {
             Tools::atkTriggerError($record, $attribs, 'error_uniquefieldset');
         }
     }
 }
开发者ID:sintattica,项目名称:atk,代码行数:44,代码来源:NodeValidator.php

示例2: validate

 /**
  * Checks if the file has a valid filetype.
  *
  * Note that obligatory and unique fields are checked by the
  * atkNodeValidator, and not by the validate() method itself.
  *
  * @param array $record The record that holds the value for this
  *                       attribute. If an error occurs, the error will
  *                       be stored in the 'atkerror' field of the record.
  * @param string $mode The mode for which should be validated ("add" or
  *                       "update")
  */
 public function validate(&$record, $mode)
 {
     parent::validate($record, $mode);
     $this->isAllowedFileType($record);
     $error = $record[$this->fieldName()]['error'];
     if ($error > 0) {
         $error_text = $this->fetchFileErrorType($error);
         Tools::atkTriggerError($record, $this, $error_text, Tools::atktext($error_text, 'atk'));
     }
 }
开发者ID:sintattica,项目名称:atk,代码行数:22,代码来源:FileAttribute.php


注:本文中的Sintattica\Atk\Core\Tools::atkTriggerError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。