本文整理汇总了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>";
}
}
示例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;
}
示例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;
}
示例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);
}
示例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'];
}
}
示例6: afterFind
/**
* @inheritdoc
*/
public function afterFind()
{
parent::afterFind();
if (empty($this->description)) {
$this->description = Inflector::camel2words($this->name, true);
}
}
示例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)]);
}
示例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;
}
示例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);
}
}
示例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)]);
});
}
示例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;
}
示例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]);
}
示例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");
}
示例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;
}
示例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'];
}
}
}