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


PHP AkInflector::conditionalPlural方法代码示例

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


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

示例1: pluralize

 /**
  * Attempts to pluralize the "$singular" word unless "$count" is 1.
  */
 function pluralize($count, $singular, $plural = null)
 {
     if ($count == 1) {
         return $singular;
     } elseif (!empty($plural)) {
         return $plural;
     } else {
         return AkInflector::conditionalPlural($count, $singular);
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:13,代码来源:text_helper.php

示例2: error_messages_for

 /**
  * Returns a string with a div containing all the error messages for the object located as an instance variable by the name
  * of <tt>object_name</tt>. This div can be tailored by the following options:
  *
  * * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
  * * <tt>id</tt> - The id of the error div (default: errorExplanation)
  * * <tt>class</tt> - The class of the error div (default: errorExplanation)
  *
  * NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
  * you need is significantly different from the default presentation, it makes plenty of sense to access the $object->getErrors()
  * instance yourself and set it up. View the source of this method to see how easy it is.
  */
 public function error_messages_for($object_name, $options = array())
 {
     $object = $this->_controller->{$object_name};
     if ($object->hasErrors()) {
         $error_list = '<ul>';
         foreach ($object->getFullErrorMessages() as $field => $errors) {
             foreach ($errors as $error) {
                 $error_list .= AkTagHelper::content_tag('li', $error);
             }
         }
         $error_list .= '</ul>';
         return AkTagHelper::content_tag('div', AkTagHelper::content_tag(!empty($options['header_tag']) ? $options['header_tag'] : 'h2', $this->t('%number_of_errors %errors prohibited this %object_name from being saved', array('%number_of_errors' => $object->countErrors(), '%errors' => $this->t(AkInflector::conditionalPlural($object->countErrors(), 'error')), '%object_name' => $this->t(AkInflector::humanize($object->getModelName()))))) . AkTagHelper::content_tag('p', $this->t('There were problems with the following fields:')) . $error_list, array('id' => !empty($options['id']) ? $options['id'] : 'errorExplanation', 'class' => !empty($options['class']) ? $options['class'] : 'errorExplanation'));
     }
 }
开发者ID:bermi,项目名称:akelos,代码行数:26,代码来源:ak_active_record_helper.php


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