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


PHP Inflector::pluralize方法代码示例

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


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

示例1: getModelSubDir

 public function getModelSubDir($model)
 {
     $pk = $model::primaryKey();
     $id = array_shift($pk);
     $modelName = $this->getShortClass($model);
     $modelDir = \yii\helpers\Inflector::pluralize($modelName) . '/' . $modelName . $model->{$id};
     return $modelDir;
 }
开发者ID:spiritabsolute,项目名称:yii2-images,代码行数:8,代码来源:Module.php

示例2: testPluralize

 public function testPluralize()
 {
     $testData = ['move' => 'moves', 'foot' => 'feet', 'child' => 'children', 'human' => 'humans', 'man' => 'men', 'staff' => 'staff', 'tooth' => 'teeth', 'person' => 'people', 'mouse' => 'mice', 'touch' => 'touches', 'hash' => 'hashes', 'shelf' => 'shelves', 'potato' => 'potatoes', 'bus' => 'buses', 'test' => 'tests', 'car' => 'cars'];
     foreach ($testData as $testIn => $testOut) {
         $this->assertEquals($testOut, Inflector::pluralize($testIn));
         $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn)));
     }
 }
开发者ID:howq,项目名称:yii2,代码行数:8,代码来源:InflectorTest.php

示例3: init

 public function init()
 {
     if (!$this->modelClass) {
         $this->modelClass = Inflector::pluralize($this->id);
     }
     \Yii::$app->request->getRawBody();
     \Yii::$app->getResponse()->getHeaders()->add('Access-Control-Allow-Origin', '*');
     parent::init();
 }
开发者ID:portalsway2,项目名称:APEDevices,代码行数:9,代码来源:Controller.php

示例4: getModelSubDir

 public function getModelSubDir()
 {
     $modelName = $this->getShortClass($this->owner);
     $modelDir = Inflector::pluralize($modelName) . '/' . $modelName . $this->owner->id;
     return $modelDir;
 }
开发者ID:infoweb-internet-solutions,项目名称:yii2-cms,代码行数:6,代码来源:FileBehave.php

示例5: getModelSubDir

 public function getModelSubDir($model)
 {
     $modelName = $this->getShortClass($model);
     $modelDir = \yii\helpers\Inflector::pluralize($modelName) . '/' . $modelName . $model->id;
     return $modelDir;
 }
开发者ID:mitrm,项目名称:yii2-images,代码行数:6,代码来源:Module.php

示例6: index

 /**
  * @return string the name of the index this record is stored in.
  */
 public static function index()
 {
     return Inflector::pluralize(Inflector::camel2id(StringHelper::basename(get_called_class()), '-'));
 }
开发者ID:aivavic,项目名称:yii2,代码行数:7,代码来源:ActiveRecord.php

示例7: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if (empty($this->controller)) {
         throw new InvalidConfigException('"controller" must be set.');
     }
     $controllers = [];
     foreach ((array) $this->controller as $urlName => $controller) {
         if (is_integer($urlName)) {
             $urlName = $this->pluralize ? Inflector::pluralize($controller) : $controller;
         }
         $controllers[$urlName] = $controller;
     }
     $this->controller = $controllers;
     $this->prefix = trim($this->prefix, '/');
     parent::init();
 }
开发者ID:sanggabee,项目名称:hellomedia-yii-basic,代码行数:19,代码来源:UrlRule.php

示例8: getPluralName

 /**
  * @return string
  */
 public function getPluralName()
 {
     return $this->_pluralName ?: Inflector::titleize(Inflector::pluralize($this->_type));
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:7,代码来源:EntityType.php

示例9: getHeading

 /**
  * Retrieves heading
  * @param boolean $plural
  */
 public function getHeading($plural = false)
 {
     $headingKey = sprintf('heading_%s', $this->getClassid(self::RK_MODEL_CM, false, '_'));
     if ($plural) {
         return self::$generator->generateString(Inflector::pluralize($headingKey));
     }
     return self::$generator->generateString($headingKey);
 }
开发者ID:dlds,项目名称:yii2-giixer,代码行数:12,代码来源:CrudHelper.php

示例10: lcfirst

                echo lcfirst($column[4][0]);
                ?>
-><?php 
                echo $column[4][1];
                ?>
 : '',
<?php 
            }
        }
    } elseif ($column[2] != 'main') {
        ?>
            isset($this->model-><?php 
        echo lcfirst(Inflector::pluralize($column[0]));
        ?>
[0]) ? $this->model-><?php 
        echo lcfirst(Inflector::pluralize($column[0]));
        ?>
[0]-><?php 
        echo $column[1]->name;
        ?>
 : '',
<?php 
    } elseif (in_array($column[3], [$generator::TYPE_DATE_AUTO, $generator::TYPE_DATE_INPUT])) {
        ?>
            Yii::$app->formatter->asDatetime($this->model-><?php 
        echo $column[1]->name;
        ?>
, I18N::getDateFormat()),
<?php 
    } elseif ($column[3] == $generator::TYPE_IMAGE_INPUT) {
        ?>
开发者ID:kalibao,项目名称:kalibao-framework,代码行数:31,代码来源:ListGridRow.php

示例11: loadAll

 public function loadAll($POST, $skippedRelations = [])
 {
     if ($this->load($POST)) {
         $shortName = StringHelper::basename(get_class($this));
         $relData = $this->getRelationData();
         foreach ($POST as $key => $value) {
             if ($key != $shortName && strpos($key, '_') === false) {
                 /* @var $AQ ActiveQuery */
                 /* @var $this ActiveRecord */
                 /* @var $relObj ActiveRecord */
                 $isHasMany = is_array($value) && is_array(current($value));
                 $relName = $isHasMany ? lcfirst(Inflector::pluralize($key)) : lcfirst($key);
                 if (in_array($relName, $skippedRelations) || !array_key_exists($relName, $relData)) {
                     continue;
                 }
                 $AQ = $this->getRelation($relName);
                 $relModelClass = $AQ->modelClass;
                 $relPKAttr = $relModelClass::primaryKey();
                 $isManyMany = count($relPKAttr) > 1;
                 if ($isManyMany) {
                     $container = [];
                     foreach ($value as $relPost) {
                         if (array_filter($relPost)) {
                             $condition = [];
                             $condition[$relPKAttr[0]] = $this->primaryKey;
                             foreach ($relPost as $relAttr => $relAttrVal) {
                                 if (in_array($relAttr, $relPKAttr)) {
                                     $condition[$relAttr] = $relAttrVal;
                                 }
                             }
                             $relObj = $relModelClass::findOne($condition);
                             if (is_null($relObj)) {
                                 $relObj = new $relModelClass();
                             }
                             $relObj->load($relPost, '');
                             $container[] = $relObj;
                         }
                     }
                     $this->populateRelation($relName, $container);
                 } else {
                     if ($isHasMany) {
                         $container = [];
                         foreach ($value as $relPost) {
                             if (array_filter($relPost)) {
                                 /* @var $relObj ActiveRecord */
                                 $relObj = empty($relPost[$relPKAttr[0]]) ? new $relModelClass() : $relModelClass::findOne($relPost[$relPKAttr[0]]);
                                 $relObj->load($relPost, '');
                                 $container[] = $relObj;
                             }
                         }
                         $this->populateRelation($relName, $container);
                     } else {
                         $relObj = empty($value[$relPKAttr[0]]) ? new $relModelClass() : $relModelClass::findOne($value[$relPKAttr[0]]);
                         $relObj->load($value, '');
                         $this->populateRelation($relName, $relObj);
                     }
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:mootensai,项目名称:yii2-relation-trait,代码行数:64,代码来源:RelationTrait.php

示例12:

?>
/* @var $dataProvider yii\data\ActiveDataProvider */

//$this->title = <?php 
echo $generator->generateString(Inflector::pluralize($nameModel));
?>
;
//$this->params['breadcrumbs'][] = $this->title;
?>
<div class="<?php 
echo Inflector::camel2id(StringHelper::basename($generator->modelClass));
?>
-index box">
    <div class="box-header with-border">
        <h1 class='box-title'><?php 
echo Inflector::pluralize($nameModel);
?>
</h1>
    </div>
    <div class="box-body table-responsive">
      
<?php 
if (!empty($generator->searchModelClass)) {
    echo "    <?php " . ($generator->indexWidgetType === 'grid' ? "// " : "");
    ?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<?php 
}
?>

    <p>
开发者ID:bruno-melo,项目名称:components,代码行数:31,代码来源:index.php

示例13: generateRelationName

 /**
  * Generate a relation name for the specified table and a base name.
  * @param string $key a base name that the relation name may be generated from
  * @param boolean $multiple whether this is a has-many relation
  * @return string the relation name
  */
 protected function generateRelationName($key, $multiple)
 {
     if (!empty($key) && substr_compare($key, 'id', -2, 2, true) === 0 && strcasecmp($key, 'id')) {
         $key = rtrim(substr($key, 0, -2), '_');
     }
     if ($multiple) {
         $key = Inflector::pluralize($key);
     }
     return Inflector::id2camel($key, '_');
 }
开发者ID:kalibao,项目名称:magesko,代码行数:16,代码来源:Generator.php

示例14: ltrim

* @var yii\web\View $this
* @var <?php 
echo ltrim($generator->modelClass, '\\');
?>
 $model
*/

$this->title = <?php 
echo $generator->generateString('Create');
?>
;
$this->params['breadcrumbs'][] = ['label' => Yii::t('<?php 
echo $generator->modelMessageCategory;
?>
', '<?php 
echo Inflector::pluralize($modelName);
?>
'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="giiant-crud <?php 
echo Inflector::camel2id(StringHelper::basename($generator->modelClass), '-', true);
?>
-create">

    <h1>
        <?php 
echo "<?= Yii::t('{$generator->modelMessageCategory}', '{$modelName}') ?>\n";
?>
        <small>
            <?php 
开发者ID:schmunk42,项目名称:yii2-giiant,代码行数:31,代码来源:create.php

示例15: labels

 /**
  * Should return an array with single and plural form of model name, e.g.
  *
  * ```php
  *  return ['User', 'Users'];
  * ```
  *
  * @return array
  */
 public static function labels()
 {
     $class = new ReflectionClass(static::className());
     $class = $class->getShortName();
     return [$class, Inflector::pluralize($class)];
 }
开发者ID:asdf-studio,项目名称:yii2-admin-module,代码行数:15,代码来源:Entity.php


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