當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inflector::camel2words方法代碼示例

本文整理匯總了PHP中yii\helpers\Inflector::camel2words方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::camel2words方法的具體用法?PHP Inflector::camel2words怎麽用?PHP Inflector::camel2words使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\helpers\Inflector的用法示例。


在下文中一共展示了Inflector::camel2words方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->header) {
         $this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
     }
 }
開發者ID:cranky4,項目名稱:change-log-behavior,代碼行數:10,代碼來源:ChangeLogList.php

示例2: getColumnHeader

 /**
  * @see \yii\grid\GridView::getColumnHeader($col)
  * @inheritdoc
  */
 public function getColumnHeader($col)
 {
     if ($col->header !== null || $col->label === null && $col->attribute === null) {
         return trim($col->header) !== '' ? $col->header : $col->grid->emptyCell;
     }
     $provider = $this->dataProvider;
     if ($col->label === null) {
         if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
             /**
              * @var \yii\db\ActiveRecord $model
              */
             $model = new $provider->query->modelClass();
             $label = $model->getAttributeLabel($col->attribute);
         } else {
             $models = $provider->getModels();
             if (($model = reset($models)) instanceof Model) {
                 $label = $model->getAttributeLabel($col->attribute);
             } else {
                 $label = Inflector::camel2words($col->attribute);
             }
         }
     } else {
         $label = $col->label;
     }
     return $label;
 }
開發者ID:ericmaicon,項目名稱:yii2-export,代碼行數:30,代碼來源:GridViewTrait.php

示例3: renderHeaderCellContent

 /**
  * @inheritdoc
  */
 public function renderHeaderCellContent()
 {
     if ($this->header !== null || $this->label === null && $this->attribute === null) {
         return parent::renderHeaderCellContent();
     }
     $provider = $this->grid->dataProvider;
     if ($this->label === null) {
         if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
             /* @var $model Model */
             $model = new $provider->query->modelClass();
             $label = $model->getAttributeLabel($this->attribute);
         } else {
             $models = $provider->getModels();
             if (($model = reset($models)) instanceof Model) {
                 /* @var $model Model */
                 $label = $model->getAttributeLabel($this->attribute);
             } else {
                 $label = Inflector::camel2words($this->attribute);
             }
         }
     } else {
         $label = $this->label;
     }
     return $label;
 }
開發者ID:yii2tech,項目名稱:csv-grid,代碼行數:28,代碼來源:DataColumn.php

示例4: wp_get_nav_menu_object

function wp_get_nav_menu_object($menu)
{
    $menu_obj = false;
    if (is_object($menu)) {
        $menu_obj = $menu;
    }
    if ($menu && !$menu_obj) {
        // if (strtolower($menu) == 'primary-menu' || strtolower($menu) == 'primary_menu') {
        $menu_obj = ['term_id' => $menu, 'name' => Inflector::camel2words($menu), 'slug' => $menu, 'term_group' => '0', 'term_taxonomy_id' => $menu, 'taxonomy' => 'nav_menu', 'description' => '', 'parent' => '0', 'count' => '1', 'filter' => 'raw'];
        $menu_obj = json_decode(json_encode($menu_obj, false));
        $menu_obj = new WP_Term($menu_obj);
        // }
        // $menu_obj = get_term( $menu, 'nav_menu' );
        // if ( ! $menu_obj ) {
        // 	$menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
        // }
        // if ( ! $menu_obj ) {
        // 	$menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
        // }
    }
    if (!$menu_obj || is_wp_error($menu_obj)) {
        $menu_obj = false;
    }
    return apply_filters('wp_get_nav_menu_object', $menu_obj, $menu);
}
開發者ID:AppItNetwork,項目名稱:yii2-wordpress-themes,代碼行數:25,代碼來源:nav-menu.php

示例5: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->attribute) {
         $field = str_replace(['[]', '][', '[', ']', ' ', '.'], ['', '-', '-', '', '-', '-'], $this->attribute);
     } else {
         $field = false;
     }
     if (empty($this->inputOptions['data-field']) && $field) {
         $this->inputOptions['data-field'] = $field;
     }
     if (empty($this->contentOptions['data-column']) && $field) {
         $this->contentOptions['data-column'] = $field;
     }
     if (empty($this->headerOptions['data-column']) && $field) {
         $this->headerOptions['data-column'] = $field;
     }
     if ($this->header === null) {
         if ($this->grid->model instanceof Model && !empty($this->attribute)) {
             $this->header = $this->grid->model->getAttributeLabel($this->attribute);
         } else {
             $this->header = Inflector::camel2words($this->attribute);
         }
     }
     if ($this->value === null) {
         $this->value = [$this, 'renderInputCell'];
     } elseif (is_string($this->value)) {
         $this->attribute = $this->value;
         $this->value = [$this, 'renderTextCell'];
     }
 }
開發者ID:mdmsoft,項目名稱:yii2-widgets,代碼行數:33,代碼來源:DataColumn.php

示例6: afterFind

 /**
  * @inheritdoc
  */
 public function afterFind()
 {
     parent::afterFind();
     if (empty($this->description)) {
         $this->description = Inflector::camel2words($this->name, true);
     }
 }
開發者ID:cakebake,項目名稱:yii2-accounts,代碼行數:10,代碼來源:AuthItem.php

示例7: actionIndex

 public function actionIndex($file)
 {
     if (!preg_match('/^[a-zA-Z0-9-_]+$/', $file)) {
         throw new HttpException(400, 'Parameter validation failed');
     }
     $html = file_get_contents(\Yii::getAlias($this->module->htmlUrl . "/{$file}.html"));
     return $this->render('index', ['html' => $html, 'headline' => Inflector::camel2words($file)]);
 }
開發者ID:schmunk42,項目名稱:yii2-markdocs-module,代碼行數:8,代碼來源:HtmlController.php

示例8: generateAttributeLabel

 public function generateAttributeLabel($name)
 {
     $label = Inflector::camel2words($name);
     // the following part is taken from Gii model generator
     if (!empty($label) && substr_compare($label, ' id', -3, 3, true) === 0) {
         $label = substr($label, 0, -3) . ' ID';
     }
     return $label;
 }
開發者ID:vitalyspirin,項目名稱:yii2-simpleactiverecord,代碼行數:9,代碼來源:SimpleActiveRecord.php

示例9: __call

 public function __call($name, $params)
 {
     $redisCommand = strtoupper(Inflector::camel2words($name, false));
     if (in_array($redisCommand, $this->redisCommands)) {
         return $this->executeCommand($name, $params);
     } else {
         return parent::__call($name, $params);
     }
 }
開發者ID:heyanlong,項目名稱:yii2-redis,代碼行數:9,代碼來源:Connection.php

示例10: getControllers

 /**
  * @param Module $module
  *
  * @return array
  */
 public function getControllers($module)
 {
     $files = FileHelper::findFiles($module->controllerPath, ['only' => ['*Controller.php']]);
     return ArrayHelper::getColumn($files, function ($file) use($module) {
         $class = pathinfo($file, PATHINFO_FILENAME);
         $route = Inflector::camel2id($class = substr($class, 0, strlen($class) - strlen('Controller')));
         return new ControllerModel(['route' => $module->uniqueId . '/' . $route, 'label' => Inflector::camel2words($class)]);
     });
 }
開發者ID:voodoo-mobile,項目名稱:yii2-api,代碼行數:14,代碼來源:Harvester.php

示例11: getElements

 public function getElements()
 {
     $files = AppHelper::findDirectories(Yii::getAlias('@worstinme/zoo/elements'));
     $files = array_unique(array_merge($files, AppHelper::findDirectories(Yii::getAlias(Yii::$app->zoo->elementsPath))));
     $elements = [];
     foreach ($files as $file) {
         $elements[$file] = Inflector::camel2words($file);
     }
     return $elements;
 }
開發者ID:worstinme,項目名稱:yii2-zoo,代碼行數:10,代碼來源:Module.php

示例12: actionIndex

 public function actionIndex()
 {
     foreach (FileHelper::findFiles($this->module->getControllerPath()) as $file) {
         $id = lcfirst(substr(basename($file), 0, -14));
         $name = Inflector::camel2words($id);
         $route = ['/' . $this->module->id . '/' . Inflector::camel2id($name)];
         $controllers[$name] = $route;
     }
     return $this->render('index', ['controllers' => $controllers]);
 }
開發者ID:schmunk42,項目名稱:yii2-sakila-module,代碼行數:10,代碼來源:DefaultController.php

示例13: actionIndex

 /**
  * @hass-todo
  */
 public function actionIndex()
 {
     $namespaces = \HassClassLoader::getHassCoreFile();
     $result = [];
     foreach ($namespaces as $namespace => $dir) {
         $controllerDir = $dir . DIRECTORY_SEPARATOR . "controllers";
         if (!is_dir($controllerDir)) {
             continue;
         }
         $files = FileHelper::findFiles($controllerDir);
         $moduleId = trim(substr($namespace, strrpos(rtrim($namespace, "\\"), "\\")), "\\");
         $result[$moduleId]["module"] = $moduleId;
         $result[$moduleId]["permissions"] = [];
         foreach ($files as $file) {
             $childDir = rtrim(pathinfo(substr($file, strpos($file, "controllers") + 12), PATHINFO_DIRNAME), ".");
             if ($childDir) {
                 $class = $namespace . "controllers\\" . str_replace("/", "\\", $childDir) . "\\" . rtrim(basename($file), ".php");
             } else {
                 $class = $namespace . "controllers\\" . rtrim(basename($file), ".php");
             }
             $controllerId = Inflector::camel2id(str_replace("Controller", "", pathinfo($file, PATHINFO_FILENAME)));
             $reflect = new \ReflectionClass($class);
             $methods = $reflect->getMethods(\ReflectionMethod::IS_PUBLIC);
             /** @var \ReflectionMethod $method */
             foreach ($methods as $method) {
                 if (!StringHelper::startsWith($method->name, "action")) {
                     continue;
                 }
                 if ($method->name == "actions") {
                     $object = \Yii::createObject(["class" => $class], [$controllerId, $moduleId]);
                     $actions = $method->invoke($object);
                     foreach ($actions as $actionId => $config) {
                         $route = $moduleId . "/" . $controllerId . "/" . $actionId;
                         if ($childDir) {
                             $route = $moduleId . "/" . $childDir . "/" . $controllerId . "/" . $actionId;
                         }
                         $result[$moduleId]["permissions"][$route] = ["type" => Item::TYPE_PERMISSION, "description" => $controllerId . "-" . Inflector::camel2words($actionId)];
                     }
                     continue;
                 }
                 $actionId = Inflector::camel2id(substr($method->name, 6));
                 $route = $moduleId . "/" . $controllerId . "/" . $actionId;
                 if ($childDir) {
                     $route = $moduleId . "/" . $childDir . "/" . $controllerId . "/" . $actionId;
                 }
                 $result[$moduleId]["permissions"][$route] = ["type" => Item::TYPE_PERMISSION, "description" => $controllerId . "-" . Inflector::camel2words(substr($method->name, 6))];
             }
         }
     }
     $result["super"] = ['module' => 'SUPER_PERMISSION', 'permissions' => array(\hass\rbac\Module::SUPER_PERMISSION => array('type' => Item::TYPE_PERMISSION, 'description' => 'SUPER_PERMISSION'))];
     $result = "<?php \n return " . var_export($result, true) . ";";
     file_put_contents(dirname(__DIR__) . "/permissions.php", $result);
     return $this->render("index");
 }
開發者ID:rocketyang,項目名稱:hasscms-app,代碼行數:57,代碼來源:ToolController.php

示例14: convertToLogical

 /**
  * @inheritdoc
  */
 protected function convertToLogical($value, $attribute)
 {
     if ($this->isEmpty($value)) {
         return null;
     }
     if (isset($this->enum[$value])) {
         return $this->enum[$value];
     }
     $names = static::names($this->owner, $this->enumPrefix);
     $str = isset($names[$value]) ? $names[$value] : '';
     return $this->toWord ? Inflector::camel2words(strtolower($str)) : $str;
 }
開發者ID:mdmsoft,項目名稱:yii2-format-converter,代碼行數:15,代碼來源:EnumConverter.php

示例15: buildUniqueRules

 public function buildUniqueRules(&$ruleList)
 {
     foreach ($this->uniqueColumnList as $columnInOneConstraintList) {
         if (count($columnInOneConstraintList) > 1) {
             $columnListAsStr = [];
             foreach ($columnInOneConstraintList as $columnName) {
                 $columnListAsStr[] = \yii\helpers\Inflector::camel2words($columnName);
             }
             $ruleList[] = [$columnInOneConstraintList, 'unique', 'targetAttribute' => $columnInOneConstraintList, 'message' => 'The combination of ' . implode(' and ', $columnListAsStr) . ' has already been taken.'];
         } else {
             $ruleList[] = [$columnInOneConstraintList, 'unique'];
         }
     }
 }
開發者ID:vitalyspirin,項目名稱:yii2-simpleactiverecord,代碼行數:14,代碼來源:YiiValidationRulesBuilder.php


注:本文中的yii\helpers\Inflector::camel2words方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。