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


PHP Inflector::classify方法代码示例

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


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

示例1: registerScripts

 public function registerScripts()
 {
     $jsonOptions = Json::encode($this->leptureOptions);
     $varName = Inflector::classify('editor' . $this->id);
     $script = "var {$varName} = new Editor(" . $jsonOptions . "); {$varName}.render();";
     $this->view->registerJs($script);
 }
开发者ID:dungphanxuan,项目名称:yii2-lepture-editor,代码行数:7,代码来源:LeptureEditorWidget.php

示例2: registerScripts

 /**
  * Registers simplemde markdown assets
  */
 public function registerScripts()
 {
     $jsonOptions = Json::encode($this->mdeOptions);
     $varName = Inflector::classify('editor' . $this->id);
     $script = "var {$varName} = new SimpleMDE(" . $jsonOptions . ");";
     $this->view->registerJs($script);
 }
开发者ID:iisns,项目名称:yii2-simplemde-markdown,代码行数:10,代码来源:Markdown.php

示例3: beforeAction

 public function beforeAction($action)
 {
     $caller = \yii::$app->getRequest()->getQueryParam('caller');
     if (!isset($caller) || $caller == '') {
         throw new \yii\base\InvalidRouteException('Module requires specification of caller parameter');
     }
     $this->_post = \yii\helpers\Inflector::classify($caller);
     $this->modelClass = $this->module->params['modelRegister'][$caller];
     return parent::beforeAction($action);
 }
开发者ID:humanized,项目名称:yii2-lookup,代码行数:10,代码来源:DefaultController.php

示例4: sprintf

echo $generator->helperCrud->getClassid(CrudHelper::RK_MODEL_CM);
?>
-form">

    <?php 
echo "<?php ";
?>
$form = ActiveForm::begin(); ?>

    <?php 
echo "<?= GxFlashHelper::alertValidation(\$model) ?>";
?>

    <?php 
if ($generator->generateMutation) {
    echo "<?=\n    \$form->field(\$model, " . ModelHelper::root($generator->helperModel->getClass(ModelHelper::RK_MODEL_CM)) . "::" . sprintf('%s%s', \dlds\giixer\Module::RELATION_NAME_PREFIX, strtoupper(Inflector::pluralize($generator->mutationSourceTableName))) . ")->widget(dlds\\rels\\widgets\\RelTabs::className(), [\n        'relView' => '/" . $generator->helperCrud->getClassid(CrudHelper::RK_MODEL_CM) . "/crud/relations/" . Inflector::camel2id(StringHelper::basename($generator->mutationJoinTableName)) . "',\n        'header' => '" . lcfirst(Inflector::classify($generator->mutationSourceTableName)) . ".title',\n        'form' => \$form,\n    ])->label(false);\n    ?>";
    ?>
    <?php 
}
?>


    <?php 
foreach ($columnNames as $attribute) {
    if (isset($safeAttributes[$attribute]) && !$safeAttributes[$attribute]->isPrimaryKey && $attribute != $generator->sortableColumnAttribute) {
        echo "<?= " . $generator->generateActiveField($attribute) . " ?>\n\n";
    }
}
?>
    <div class="form-group">
        <?php 
开发者ID:dlds,项目名称:yii2-giixer,代码行数:31,代码来源:_form.php

示例5: actionDetail

     * @throws NotFoundHttpException
     */
    public function actionDetail(<?php 
echo $actionParams;
?>
)
    {
        $model = <?php 
echo StringHelper::basename($generator->modelClass);
?>
::find()
<?php 
foreach ($pks as $pk) {
    ?>
            ->findBy<?php 
    echo Inflector::classify($pk);
    ?>
($<?php 
    echo $pk;
    ?>
)
<?php 
}
?>
            ->one();

        if ($model) {
            $data = $model->toArray();
            <?php 
echo $generator->generateSuccessData(3, '$data') . "\n";
?>
开发者ID:myweishanli,项目名称:yii2-gii,代码行数:31,代码来源:controller.php

示例6: testClassify

 public function testClassify()
 {
     $this->assertEquals("CustomerTable", Inflector::classify('customer_tables'));
 }
开发者ID:howq,项目名称:yii2,代码行数:4,代码来源:InflectorTest.php

示例7: generate

 /**
  * @inheritdoc
  */
 public function generate()
 {
     $db = $this->getDbConnection();
     $files = [];
     $tables = [];
     $this->getTableNames();
     $counter = 0;
     foreach ($this->tableNames as $table) {
         $tables[$counter]['url'] = strtolower(Inflector::classify($table)) . "/table";
         $tables[$counter]['comma'] = count($this->tableNames) == count($tables) ? '' : ',';
         $tables[$counter++]['name'] = $table;
     }
     foreach ($this->tableNames as $table) {
         $tableSchema = $db->getTableSchema($table);
         $primaryKey = $tableSchema->primaryKey[0];
         $fieldsArray = [];
         $headersArray = [];
         foreach ($tableSchema->columns as $column) {
             if (!$column->autoIncrement) {
                 array_push($fieldsArray, $column->name);
                 array_push($headersArray, Inflector::humanize($column->name));
             }
         }
         $fields = implode(',', $fieldsArray);
         $headers = implode(',', $headersArray);
         $modelControllerName = ucfirst(strtolower(Inflector::classify($table)));
         $files[] = new CodeFile($this->getModelFile($modelControllerName), $this->render('model.php', ['fields' => $fields, 'rules' => $this->generateRules($tableSchema), 'modelName' => $modelControllerName, 'primaryKey' => $primaryKey, 'tableName' => $table]));
         $files[] = new CodeFile($this->getControllerFile($modelControllerName), $this->render('controller.php', ['fields' => $fields, 'controllerName' => $modelControllerName, 'modelName' => $modelControllerName, 'primaryKey' => $primaryKey]));
         $files[] = new CodeFile($this->getViewFile($modelControllerName), $this->render('view.php', ['headers' => $headers, 'tableName' => $table, 'tables' => $tables, 'controllerName' => strtolower($modelControllerName)]));
     }
     $files[] = new CodeFile(Yii::getAlias($this->viewPath) . '/layouts/fullscreen.php', $this->render('layout.php'));
     $this->lastControllerName = $modelControllerName;
     return $files;
 }
开发者ID:dhtmlx,项目名称:dhtmlx-gii,代码行数:37,代码来源:Generator.php

示例8: foreach

            foreach ($this-><?php 
    echo Inflector::pluralize($primaryKey);
    ?>
 as $<?php 
    echo $primaryKey;
    ?>
) {
                $<?php 
    echo $modelVarName;
    ?>
 = <?php 
    echo $modelClassName;
    ?>
::find()
                    ->findBy<?php 
    echo Inflector::classify($primaryKey);
    ?>
($<?php 
    echo $primaryKey;
    ?>
)
                    ->one();
                if ($<?php 
    echo $modelVarName;
    ?>
) {
                    if (!$<?php 
    echo $modelVarName;
    ?>
->delete()) {
                        if ($<?php 
开发者ID:myweishanli,项目名称:yii2-gii,代码行数:31,代码来源:model.php

示例9: actionSearchModels

 public function actionSearchModels()
 {
     foreach (Yii::$app->getDb()->createCommand('SHOW FULL TABLES;')->queryAll(\PDO::FETCH_NUM) as $row) {
         list($tableName, $tableType) = $row;
         $ns = $tableType == 'VIEW' ? 'app\\models\\readonly\\search' : 'app\\models\\search';
         $modelName = Inflector::classify($tableName);
         $modelClass = $ns . '\\' . $modelName . 'SearchBase';
         $secondModelClass = $ns . '\\' . $modelName . 'Search';
         $this->_commands[$secondModelClass] = ['gii/search2', 'modelClass' => $modelClass, 'secondModelClass' => $secondModelClass, 'interactive' => 0, 'overwrite' => 1];
     }
 }
开发者ID:ivan-chkv,项目名称:yii2-kladovka,代码行数:11,代码来源:GenerateController.php

示例10: fixRelations

 /**
  * @param array $generatedRelations
  * @return array
  */
 protected function fixRelations(array $generatedRelations)
 {
     foreach ($generatedRelations as $tableName => $tableRelations) {
         $fixRelationNames = [];
         foreach ($tableRelations as $relationName => $relation) {
             if (preg_match('~^(\\D+)\\d+$~', $relationName, $match)) {
                 $fixRelationNames[] = $match[1];
             }
         }
         foreach ($fixRelationNames as $fixRelationName) {
             foreach ($tableRelations as $relationName => $relation) {
                 if ($relationName == $fixRelationName) {
                     if (isset($tableRelations[$relationName])) {
                         $tableRelations[$relationName . '99'] = $tableRelations[$relationName];
                         unset($tableRelations[$relationName]);
                     }
                     if (isset($generatedRelations[$tableName][$relationName])) {
                         $generatedRelations[$tableName][$relationName . '99'] = $generatedRelations[$tableName][$relationName];
                         unset($generatedRelations[$tableName][$relationName]);
                     }
                     if (isset($this->allRelations[$tableName][$relationName])) {
                         $this->allRelations[$tableName][$relationName . '99'] = $this->allRelations[$tableName][$relationName];
                         unset($this->allRelations[$tableName][$relationName]);
                     }
                     if (isset($this->singularRelations[$tableName][$relationName])) {
                         $this->singularRelations[$tableName][$relationName . '99'] = $this->singularRelations[$tableName][$relationName];
                         unset($this->singularRelations[$tableName][$relationName]);
                     }
                     if (isset($this->pluralRelations[$tableName][$relationName])) {
                         $this->pluralRelations[$tableName][$relationName . '99'] = $this->pluralRelations[$tableName][$relationName];
                         unset($this->pluralRelations[$tableName][$relationName]);
                     }
                 }
             }
         }
         foreach ($fixRelationNames as $fixRelationName) {
             foreach ($tableRelations as $relationName => $relation) {
                 if (preg_match('~^(\\D+)\\d+$~', $relationName, $match) && $match[1] == $fixRelationName) {
                     $relation = $this->allRelations[$tableName][$relationName];
                     if ($relation['hasMany']) {
                         $linkKeys = array_keys($relation['link']);
                         if (count($linkKeys) == 1) {
                             $linkKey = preg_replace('~_id$~', '', $linkKeys[0]);
                             if ($tableName == $linkKey) {
                                 $relationName2 = $fixRelationName;
                             } else {
                                 $relationName2 = Inflector::classify($linkKey);
                                 $relationName2 = str_replace(Inflector::singularize($fixRelationName), '', $relationName2);
                                 $relationName2 .= $fixRelationName;
                             }
                             echo $relationName, ' -> ', $relationName2, "\n";
                             if (isset($tableRelations[$relationName])) {
                                 $tableRelations[$relationName2] = $tableRelations[$relationName];
                                 unset($tableRelations[$relationName]);
                             }
                             if (isset($generatedRelations[$tableName][$relationName])) {
                                 $generatedRelations[$tableName][$relationName2] = $generatedRelations[$tableName][$relationName];
                                 unset($generatedRelations[$tableName][$relationName]);
                             }
                             if (isset($this->allRelations[$tableName][$relationName])) {
                                 $this->allRelations[$tableName][$relationName2] = $this->allRelations[$tableName][$relationName];
                                 unset($this->allRelations[$tableName][$relationName]);
                             }
                             if (isset($this->singularRelations[$tableName][$relationName])) {
                                 $this->singularRelations[$tableName][$relationName2] = $this->singularRelations[$tableName][$relationName];
                                 unset($this->singularRelations[$tableName][$relationName]);
                             }
                             if (isset($this->pluralRelations[$tableName][$relationName])) {
                                 $this->pluralRelations[$tableName][$relationName2] = $this->pluralRelations[$tableName][$relationName];
                                 unset($this->pluralRelations[$tableName][$relationName]);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $generatedRelations;
 }
开发者ID:ivan-chkv,项目名称:yii2-gii-plus,代码行数:83,代码来源:Generator.php

示例11: prepareFields

 protected function prepareFields(BaseActiveRecord $model)
 {
     $modelClass = get_class($model);
     $validKeys = $model->attributes();
     $fields = ModelHelper::normalizeBrackets(ModelHelper::expandBrackets($this->fields ?: ModelHelper::formFields($model), $validKeys), $validKeys);
     foreach ($model->getBehaviors() as $behavior) {
         if ($behavior instanceof DatetimeBehavior) {
             foreach ($behavior->attributes as $datetimeAttribute) {
                 if (array_key_exists($datetimeAttribute, $fields) && !array_key_exists('type', $fields[$datetimeAttribute])) {
                     $fields[$datetimeAttribute]['type'] = 'datetime';
                 }
             }
         } elseif ($behavior instanceof SoftDeleteBehavior) {
             if (array_key_exists($behavior->deletedAttribute, $fields)) {
                 $fields[$behavior->deletedAttribute]['visible'] = false;
             }
         } elseif ($behavior instanceof TimeDeleteBehavior) {
             if (array_key_exists($behavior->deletedAtAttribute, $fields)) {
                 $fields[$behavior->deletedAtAttribute]['visible'] = false;
             }
         } elseif ($behavior instanceof TimestampBehavior) {
             if (array_key_exists($behavior->createdAtAttribute, $fields)) {
                 $fields[$behavior->createdAtAttribute]['readOnly'] = true;
             }
             if (array_key_exists($behavior->updatedAtAttribute, $fields)) {
                 $fields[$behavior->updatedAtAttribute]['readOnly'] = true;
             }
             if (array_key_exists($behavior->timestampAttribute, $fields)) {
                 $fields[$behavior->timestampAttribute]['readOnly'] = true;
             }
         }
     }
     $tableSchema = $modelClass::getTableSchema();
     foreach ($tableSchema->foreignKeys as $foreignKey) {
         if (count($foreignKey) == 2) {
             $relatedQueryMethod = 'get' . Inflector::classify($foreignKey[0]);
             if (method_exists($model, $relatedQueryMethod) && is_callable([$model, $relatedQueryMethod])) {
                 $relatedAttribute = array_keys($foreignKey)[1];
                 $fields[$relatedAttribute]['type'] = 'dropDownList';
                 $fields[$relatedAttribute]['items'] = ModelHelper::listItems($model->{$relatedQueryMethod}());
             }
         }
     }
     foreach ($fields as $attribute => $options) {
         if (!array_key_exists('type', $options)) {
             $listItemsMethod = Inflector::variablize($attribute) . 'ListItems';
             if (method_exists($modelClass, $listItemsMethod) && is_callable([$modelClass, $listItemsMethod])) {
                 $options['type'] = 'dropDownList';
                 $options['items'] = $modelClass::$listItemsMethod($model);
             }
         }
         $columnSchema = $tableSchema->getColumn($attribute);
         if ($columnSchema) {
             if ($columnSchema->isPrimaryKey && !method_exists($model, 'search')) {
                 if (!$model->getIsNewRecord()) {
                     $options['readOnly'] = true;
                 } elseif ($columnSchema->autoIncrement) {
                     $options['visible'] = false;
                 }
             }
             if (!array_key_exists('type', $options)) {
                 $options['type'] = $columnSchema->type;
                 if (in_array($columnSchema->type, ['tinyint', 'smallint', 'integer', 'bigint'])) {
                     if ($columnSchema->size == 1 && $columnSchema->unsigned) {
                         $options['type'] = 'boolean';
                     } else {
                         $options['size'] = $columnSchema->size;
                         $options['unsigned'] = $columnSchema->unsigned;
                     }
                 } elseif (in_array($columnSchema->type, ['decimal', 'numeric', 'money'])) {
                     $options['size'] = $columnSchema->size;
                     $options['scale'] = $columnSchema->scale;
                     $options['unsigned'] = $columnSchema->unsigned;
                 } elseif ($columnSchema->type == 'string') {
                     $options['size'] = $columnSchema->size;
                 }
             }
         }
         if (array_key_exists('type', $options)) {
             if ($options['type'] && is_string($options['type'])) {
                 if ($options['type'] == 'invisible') {
                     $options['visible'] = false;
                 } elseif (!array_key_exists('class', $options)) {
                     $fieldClass = 'yii\\mozayka\\form\\' . Inflector::id2camel($options['type']) . 'Field';
                     if (class_exists($fieldClass)) {
                         $options['class'] = $fieldClass;
                     }
                 }
             }
             unset($options['type']);
         }
         $fields[$attribute] = $options;
     }
     return array_filter($fields, function ($options) {
         return !array_key_exists('visible', $options) || $options['visible'];
     });
 }
开发者ID:ivan-chkv,项目名称:yii2-mozayka,代码行数:97,代码来源:Action.php

示例12: getGatewayClassByName

 /**
  * @param string $name
  * @return string
  * @throws NotFoundGatewayException
  */
 protected function getGatewayClassByName($name)
 {
     $className = __NAMESPACE__ . '\\gateways\\' . Inflector::classify($name);
     if (!class_exists($className)) {
         throw new NotFoundGatewayException('Gateway `' . $name . '` is not found.');
     }
     return $className;
 }
开发者ID:affka,项目名称:yii2-gateway,代码行数:13,代码来源:GatewayModule.php


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