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


PHP Inflector::camel2id方法代码示例

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


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

示例1: getViewPath

 /**
  * Find view paths in application folder.
  *
  * {@inheritDoc}
  *
  * @see \yii\base\Widget::getViewPath()
  * @return string
  */
 public function getViewPath()
 {
     // get reflection
     $class = new ReflectionClass($this);
     // get path with alias
     return '@app/views/widgets/' . Inflector::camel2id($class->getShortName());
 }
开发者ID:luyadev,项目名称:luya-core,代码行数:15,代码来源:Widget.php

示例2: renderDataCellContent

 protected function renderDataCellContent($model, $key, $index)
 {
     if ($this->count) {
         $count = call_user_func($this->count, $model, $key, $index, $this);
         // Deprecated: use `self::$count`
     } elseif ($this->countField) {
         $count = $model->{$this->countField};
     } elseif ($this->modelClass) {
         $childModelClass = $this->modelClass;
         $count = $childModelClass::find()->where([$this->modelField => $key])->permission()->count();
     } else {
         throw new Exception("Count is empty");
     }
     if (empty($count) && !$this->showEmpty) {
         return '';
     }
     $content = Html::tag('span', $count, ['class' => 'badge']);
     // Deprecated: Use `DataColumn::$link`
     if ($this->needUrl && $this->modelClass && $this->modelField) {
         // need url
         $childModel = new $childModelClass();
         if (empty($this->urlPath)) {
             $this->urlPath = Inflector::camel2id($childModel->formName()) . '/index';
         }
         if (empty($this->searchFieldName)) {
             $this->searchFieldName = $this->modelField;
             if ($this->dirtyUrl) {
                 $this->searchFieldName = $childModel->formName() . 'Search[' . $this->modelField . ']';
             }
         }
         $url = Url::to([$this->urlPath, $this->searchFieldName => $key]);
         return Html::a($content, $url);
     }
     return $this->dataCellContentWrapper($content, $model);
 }
开发者ID:vsguts,项目名称:crm,代码行数:35,代码来源:CounterColumn.php

示例3: bOrderAttr

 public static function bOrderAttr()
 {
     if (is_null(static::$b_order_attr)) {
         static::$b_order_attr = Inflector::camel2id(StringHelper::basename(static::bClass()), '_') . '_ord';
     }
     return static::$b_order_attr;
 }
开发者ID:omidonix,项目名称:yii2-sortable-behavior,代码行数:7,代码来源:PivotRecord.php

示例4: tableName

 /**
  * @inheritdoc
  */
 public static function tableName()
 {
     $name = Inflector::camel2id(StringHelper::basename(get_called_class()), '_');
     $length = mb_strlen($name, \Yii::$app->charset) - 7;
     // - mb_strlen('_record', Yii::$app->charset);
     return '{{%' . trim(mb_substr($name, 0, $length, \Yii::$app->charset)) . '}}';
 }
开发者ID:just-leo,项目名称:cardgame-serial,代码行数:10,代码来源:ActiveRecord.php

示例5: getLink

 /**
  * @param $class
  * @param $id
  * @param array $options
  * @return string
  */
 public static function getLink($class, $id, $options = [])
 {
     list($app, $module, $moduleName, $model, $modelName) = explode('\\', $class);
     list($modulePath, $modelPath) = [Inflector::camel2id($moduleName), Inflector::camel2id($modelName)];
     $modelName = $modulePath == $modelPath || $modelPath == 'item' ? $moduleName : "{$moduleName} {$modelName}";
     return $id ? Html::a("{$modelName}#{$id}", ["/{$modulePath}/{$modelPath}/view", 'id' => $id], $options) : Html::a("{$modelName}", ["/{$modulePath}/{$modelPath}/index"], $options);
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:13,代码来源:ModelHelper.php

示例6: getRoute

 /**
  * @return string
  */
 protected function getRoute()
 {
     if (Yii::$app->requestedAction) {
         return \yii\helpers\Inflector::camel2id(Yii::$app->requestedAction->getUniqueId());
     }
     return Yii::$app->requestedRoute;
 }
开发者ID:brucealdridge,项目名称:yii2-audit,代码行数:10,代码来源:RequestPanel.php

示例7: actionIndex

 public function actionIndex()
 {
     $actions = [];
     $rc = new \ReflectionClass($this);
     $publicMethods = $rc->getMethods(\ReflectionMethod::IS_PUBLIC);
     $availableActions = [];
     foreach ($publicMethods as $publicMethod) {
         $methodName = $publicMethod->name;
         if ($methodName == 'actions') {
             continue;
         }
         if (StringHelper::startsWith($methodName, 'action')) {
             $availableActions[] = $methodName;
         }
     }
     if (count($this->actions()) > 0) {
         $availableActions = $availableActions + array_keys($this->actions());
     }
     $menus = [];
     foreach ($availableActions as $actionName) {
         $routeId = Inflector::camel2id(substr($actionName, strlen('action')));
         $menus[] = Html::a($actionName, [$routeId]);
     }
     echo implode('<br/>', $menus);
 }
开发者ID:cjq,项目名称:yii2-playground,代码行数:25,代码来源:SsdbController.php

示例8: testCamel2id

 public function testCamel2id()
 {
     $this->assertEquals('post-tag', Inflector::camel2id('PostTag'));
     $this->assertEquals('post_tag', Inflector::camel2id('PostTag', '_'));
     $this->assertEquals('post-tag', Inflector::camel2id('postTag'));
     $this->assertEquals('post_tag', Inflector::camel2id('postTag', '_'));
 }
开发者ID:rajanishtimes,项目名称:basicyii,代码行数:7,代码来源:InflectorTest.php

示例9: actionRoute

 public function actionRoute()
 {
     Yii::$app->response->format = 'json';
     $controllerlist = [];
     $name = Yii::getAlias('@app');
     $pos = strrpos($_GET['title'], '\\');
     $class = substr(substr($_GET['title'], $pos + 0), 0, -10);
     $nameController = Inflector::camel2id($class);
     if ($views = opendir($name . '/views/' . $nameController)) {
         while (false !== ($file = readdir($views))) {
             $viewlist[] = $file;
         }
         closedir($views);
     }
     $fulllist = [];
     $handle = fopen($name . '/controllers/' . $_GET['title'] . ".php", "r");
     if ($handle) {
         while (($line = fgets($handle)) !== false) {
             if (preg_match('/public function action(.*?)\\(/', $line, $display)) {
                 if (strlen($display[1]) > 2) {
                     $actionname = Inflector::camel2id($display[1]);
                     $nameController = Inflector::camel2id($class);
                     $fulllist['url'][strtolower($nameController . '/' . $actionname)][] = strtolower($nameController . '/' . $actionname);
                 }
             }
         }
     }
     fclose($handle);
     return $fulllist;
 }
开发者ID:spanjeta,项目名称:yii2-seo,代码行数:30,代码来源:SeomanagerController.php

示例10: run

 public function run()
 {
     $controllerId = Inflector::camel2id($this->itemClass);
     $translatedWordItems = $this->itemClass == 'Page' ? \Yii::t('back', 'pages') : \Yii::t('back', 'articles');
     $translatedWordItems2 = $this->itemClass == 'Page' ? \Yii::t('back', 'of pages') : \Yii::t('back', 'of articles');
     $contentType = $this->itemClass == 'Page' ? ContentRecord::TYPE_PAGE : ContentRecord::TYPE_ARTICLE;
     return $this->render('recentContent', ['items' => $this->_items, 'controllerId' => $controllerId, 'translatedWordItems' => $translatedWordItems, 'translatedWordItems2' => $translatedWordItems2, 'contentType' => $contentType]);
 }
开发者ID:czechcamus,项目名称:dasport,代码行数:8,代码来源:RecentContent.php

示例11: idAttr

 protected function idAttr()
 {
     if (is_null($this->pivotIdAttr)) {
         $owner = $this->owner;
         $this->pivotIdAttr = Inflector::camel2id(StringHelper::basename($owner->className()), '_') . '_id';
     }
     return $this->pivotIdAttr;
 }
开发者ID:menshakov,项目名称:yii2-sortable-behavior,代码行数:8,代码来源:MMSortable.php

示例12: getFilenameFor

 /**
  * @param  ActiveRecord $activeRecord
  * @param               $attribute
  * @param null $extension
  *
  * @return string
  */
 public function getFilenameFor($activeRecord, $attribute, $extension = null)
 {
     $path = Inflector::camel2id((new \ReflectionClass($activeRecord))->getShortName());
     $basename = implode('-', $activeRecord->getPrimaryKey(true)) . '-' . $attribute;
     if ($extension) {
         $basename .= '.' . $extension;
     }
     return $path . DIRECTORY_SEPARATOR . $basename;
 }
开发者ID:voodoo-mobile,项目名称:yii2-upload,代码行数:16,代码来源:Writer.php

示例13: 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

示例14: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!isset($this->counterOwner) || !is_array($this->counterOwner) && !is_object($this->counterOwner)) {
         throw new InvalidConfigException('counterOwner must be configured as array or object');
     }
     if (!isset($this->counterParam)) {
         $this->counterParam = Inflector::camel2id(StringHelper::basename(get_class($this->counterOwner))) . '_count';
     }
 }
开发者ID:yii2-tools,项目名称:yii2-base,代码行数:13,代码来源:CountableBehavior.php

示例15: init

 /**
  * Initialize attributes
  *
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     if (!$this->model) {
         throw new InvalidConfigException('Model is missing');
     }
     $this->_modelName = $this->model instanceof ActiveRecord ? Inflector::camel2id(StringHelper::basename(get_class($this->model))) : $this->model;
     if (!$this->storageId) {
         $this->storageId = $this->_modelName;
     }
 }
开发者ID:webvimark,项目名称:form-fields-visibility,代码行数:15,代码来源:FormFieldsVisibility.php


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