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


PHP Inflector::camelize方法代码示例

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


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

示例1: callback

 public function callback(AMQPMessage $msg)
 {
     $routingKey = $msg->get('routing_key');
     $method = 'read' . Inflector::camelize($routingKey);
     $interpreter = isset($this->interpreters[$this->exchange]) ? $this->interpreters[$this->exchange] : (isset($this->interpreters['*']) ? $this->interpreters['*'] : null);
     if ($interpreter === null) {
         $interpreter = $this;
     } else {
         if (class_exists($interpreter)) {
             $interpreter = new $interpreter();
             if (!$interpreter instanceof AmqpInterpreter) {
                 throw new Exception(sprintf("Class '%s' is not correct interpreter class.", $interpreter));
             }
         } else {
             throw new Exception(sprintf("Interpreter class '%s' was not found.", $interpreter));
         }
     }
     if (method_exists($interpreter, $method) || is_callable([$interpreter, $method])) {
         $info = ['exchange' => $this->exchange, 'routing_key' => $routingKey, 'reply_to' => $msg->has('reply_to') ? $msg->get('reply_to') : null, 'delivery_tag' => $msg->get('delivery_tag')];
         try {
             $body = Json::decode($msg->body, true);
         } catch (\Exception $e) {
             $body = $msg->body;
         }
         $interpreter->{$method}($body, $info, $this->amqp->channel);
     } else {
         if (!$interpreter instanceof AmqpInterpreter) {
             $interpreter = new AmqpInterpreter();
         }
         $interpreter->log(sprintf("Unknown routing key '%s' for exchange '%s'.", $routingKey, $this->exchange), $interpreter::MESSAGE_ERROR);
         // debug the message
         $interpreter->log(print_r(Json::decode($msg->body, true), true), $interpreter::MESSAGE_INFO);
     }
 }
开发者ID:vstaheev,项目名称:yii2-amqp,代码行数:34,代码来源:AmqpListenerController.php

示例2: callback

 public function callback(AMQPMessage $msg)
 {
     $routingKey = $msg->delivery_info['routing_key'];
     $method = 'read' . Inflector::camelize($routingKey);
     if (!isset($this->interpreters[$this->exchange])) {
         $interpreter = $this;
     } elseif (class_exists($this->interpreters[$this->exchange])) {
         $interpreter = new $this->interpreters[$this->exchange]();
         if (!$interpreter instanceof AmqpInterpreter) {
             throw new Exception(sprintf("Class '%s' is not correct interpreter class.", $this->interpreters[$this->exchange]));
         }
     } else {
         throw new Exception(sprintf("Interpreter class '%s' was not found.", $this->interpreters[$this->exchange]));
     }
     if (method_exists($interpreter, $method)) {
         $info = ['exchange' => $msg->get('exchange'), 'routing_key' => $msg->get('routing_key'), 'reply_to' => $msg->has('reply_to') ? $msg->get('reply_to') : null];
         $interpreter->{$method}(Json::decode($msg->body, true), $info);
     } else {
         if (!isset($this->interpreters[$this->exchange])) {
             $interpreter = new AmqpInterpreter();
         }
         $interpreter->log(sprintf("Unknown routing key '%s' for exchange '%s'.", $routingKey, $this->exchange), $interpreter::MESSAGE_ERROR);
         // debug the message
         $interpreter->log(print_r(Json::decode($msg->body, true), true), $interpreter::MESSAGE_INFO);
     }
 }
开发者ID:LexxanderDream,项目名称:yii2-amqp,代码行数:26,代码来源:AmqpListenerController.php

示例3: actionIndex

 /**
  * This command echoes what you have entered as the message.
  *
  * @param string $message the message to be echoed.
  */
 public function actionIndex()
 {
     echo "Running batch...\n";
     $config = $this->getYiiConfiguration();
     $config['id'] = 'temp';
     // create models
     foreach ($this->tables as $table) {
         #var_dump($this->tableNameMap, $table);exit;
         $params = ['interactive' => $this->interactive, 'template' => 'default', 'ns' => $this->modelNamespace, 'db' => $this->modelDb, 'tableName' => $table, 'tablePrefix' => $this->tablePrefix, 'generateModelClass' => $this->extendedModels, 'modelClass' => isset($this->tableNameMap[$table]) ? $this->tableNameMap[$table] : Inflector::camelize($table), 'baseClass' => $this->modelBaseClass, 'tableNameMap' => $this->tableNameMap];
         $route = 'gii/giix-model';
         $app = \Yii::$app;
         $temp = new \yii\console\Application($config);
         $temp->runAction(ltrim($route, '/'), $params);
         unset($temp);
         \Yii::$app = $app;
     }
     // create CRUDs
     $providers = ArrayHelper::merge($this->crudProviders, Generator::getCoreProviders());
     foreach ($this->tables as $table) {
         $table = str_replace($this->tablePrefix, '', $table);
         $name = isset($this->tableNameMap[$table]) ? $this->tableNameMap[$table] : Inflector::camelize($table);
         $params = ['interactive' => $this->interactive, 'overwrite' => $this->overwrite, 'template' => 'default', 'modelClass' => $this->modelNamespace . '\\' . $name, 'searchModelClass' => $this->modelNamespace . '\\search\\' . $name . 'Search', 'controllerClass' => $this->crudControllerNamespace . '\\' . $name . 'Controller', 'viewPath' => $this->crudViewPath, 'pathPrefix' => $this->crudPathPrefix, 'actionButtonClass' => 'yii\\grid\\ActionColumn', 'baseControllerClass' => $this->crudBaseControllerClass, 'providerList' => implode(',', $providers)];
         $route = 'gii/giix-crud';
         $app = \Yii::$app;
         $temp = new \yii\console\Application($config);
         $temp->runAction(ltrim($route, '/'), $params);
         unset($temp);
         \Yii::$app = $app;
     }
 }
开发者ID:nathanphan,项目名称:yii2-giix,代码行数:35,代码来源:BatchController.php

示例4: getLabel

 /**
  * @return array
  */
 function getLabel()
 {
     $res = [];
     $get = $this->get;
     $attr = $this->attribute;
     $label = $this->label;
     if ($get[$attr] || $get[$attr] == '0') {
         $label = $label ? $label : $this->model->getAttributeLabel($attr) . ':';
         if ($this->getRelationName === true) {
             if (is_array($get[$attr])) {
                 $val = implode(', ', $get[$attr]);
             } else {
                 $strMod = substr(Inflector::camelize($attr), 0, -2);
                 $val = $this->model->{lcfirst($strMod)}->name;
             }
         } elseif ($this->value instanceof Closure) {
             $val = $this->renderDataCell($this->model, $get[$attr]);
         } elseif (!$this->value instanceof Closure && $this->value) {
             $val = $this->value;
         } else {
             if (is_array($get[$attr])) {
                 $val = implode(', ', $get[$attr]);
             } else {
                 $val = $get[$attr];
             }
         }
         $res = ['attr' => $attr, 'label' => $label, 'value' => $val];
     }
     return $res;
 }
开发者ID:vykhrystiuk,项目名称:yii2-filter-tab,代码行数:33,代码来源:ColumnsTab.php

示例5: setBlockName

 /**
  * Setter method for $blockName, ensure the correct block name.
  *
  * @param string $name The name of the block.
  */
 public function setBlockName($name)
 {
     if (!StringHelper::endsWith($name, 'Block')) {
         $name .= 'Block';
     }
     $this->_blockName = Inflector::camelize($name);
 }
开发者ID:luyadev,项目名称:luya-core,代码行数:12,代码来源:BlockController.php

示例6: createClassName

 /**
  * Generates a class name with camelcase style and specific suffix, if not already provided
  *
  * @param string $string The name of the class, e.g.: hello_word would
  * @param string $suffix The suffix to append on the class name if not eixsts, e.g.: MySuffix
  * @return string The class name e.g. HelloWorldMySuffix
  * @since 1.0.0-beta4
  */
 public function createClassName($string, $suffix = false)
 {
     $name = Inflector::camelize($string);
     if ($suffix && StringHelper::endsWith($name, $suffix, false)) {
         $name = substr($name, 0, -strlen($suffix));
     }
     return $name . $suffix;
 }
开发者ID:aekkapun,项目名称:luya,代码行数:16,代码来源:Command.php

示例7: params

 /**
  * get link parameters for menu access
  *
  * @param String $name
  * @param Array $options
  * @return Array
  */
 static function params($name = '', $options = ['url' => '#'])
 {
     $method = 'params' . Inflector::camelize($name);
     if (method_exists(static::className(), $method)) {
         return ArrayHelper::merge(static::$method(), $options);
     }
     return $options;
 }
开发者ID:AlvaCorp,项目名称:yii2-boilerplate,代码行数:15,代码来源:ModelAccess.php

示例8: callbackButton

 /**
  *
  * @param string $value The name/value of the button to display for the user.
  * @param string $callback The id of the callback if the callback method s name is `callbackSayHello` the callback id would be `say-hello`.
  * @param array $options Define behavior of the button, options are name-value pairs. The following options are available:
  *
  * - params: array, Add additional parameters which will be sent to the callback. ['foo' => 'bar']
  * - closeOnSuccess: boolean, if enabled, the active window will close after successfully sendSuccess() response from callback.
  * - reloadListOnSuccess: boolean, if enabled, the active window will reload the ngrest crud list after success response from callback via sendSuccess().
  * - reloadWindowOnSuccess: boolena, if enabled the active window will reload itself after success (when successResponse is returnd).
  * - class: string, html class fur the button
  * @return string
  */
 public function callbackButton($value, $callback, array $options = [])
 {
     // do we have option params for the button
     $params = array_key_exists('params', $options) ? $options['params'] : [];
     // create the angular controller name
     $controller = 'Controller' . Inflector::camelize($value) . Inflector::camelize($callback);
     // render and return the view with the specific params
     return $this->render('@admin/views/aws/base/_callbackButton', ['angularCrudControllerName' => $controller, 'callbackName' => $this->callbackConvert($callback), 'callbackArgumentsJson' => Json::encode($params), 'buttonNameValue' => $value, 'closeOnSuccess' => isset($options['closeOnSuccess']) ? '$scope.crud.closeActiveWindow();' : null, 'reloadListOnSuccess' => isset($options['reloadListOnSuccess']) ? '$scope.crud.loadList();' : null, 'reloadWindowOnSuccess' => isset($options['reloadWindowOnSuccess']) ? '$scope.$parent.activeWindowReload();' : null, 'buttonClass' => isset($options['class']) ? $options['class'] : 'btn']);
 }
开发者ID:luyadev,项目名称:luya-module-admin,代码行数:22,代码来源:ActiveWindowView.php

示例9: validateAttribute

 /**
  * @inheritdoc
  */
 public function validateAttribute($model, $attribute)
 {
     $this->model = $this->model ?: $model;
     $method = Inflector::camelize(str_replace('_id', '', $attribute) . 'List');
     $list = $this->list === null ? array_keys($this->model->{$method}()) : $this->list;
     $result = is_array($model->{$attribute}) ? !array_diff($model->{$attribute}, $list) : in_array($model->{$attribute}, $list);
     if (!$result) {
         $this->addError($model, $attribute, $this->message ?: \Yii::t('app', 'Forbidden value'));
     }
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:13,代码来源:ListValidator.php

示例10: validateName

 public function validateName($attribute)
 {
     $name = Inflector::camelize(Inflector::slug($this->{$attribute}));
     $label = $this->getAttributeLabel($attribute);
     if (empty($name)) {
         $this->addError($attribute, "'{$label}' должно состоять только из букв и цифр");
     } else {
         $this->{$attribute} = $name;
     }
 }
开发者ID:shubnikofff,项目名称:teleport,代码行数:10,代码来源:RoleForm.php

示例11: webhook

 public function webhook($data)
 {
     if (!empty($data['event'])) {
         $method = lcfirst(Inflector::camelize($data['event']));
         if (method_exists($this, $method)) {
             return $this->{$method}($data);
         }
     }
     return false;
 }
开发者ID:vvkgpt48,项目名称:merchium-advanced-app,代码行数:10,代码来源:WebhookBehavior.php

示例12: actionExists

 /**
  * Checks whether action with specified ID exists in owner controller.
  * @param string $id action ID.
  * @return boolean whether action exists or not.
  */
 public function actionExists($id)
 {
     $inlineActionMethodName = 'action' . Inflector::camelize($id);
     if (method_exists($this->controller, $inlineActionMethodName)) {
         return true;
     }
     if (array_key_exists($id, $this->controller->actions())) {
         return true;
     }
     return false;
 }
开发者ID:ASP96,项目名称:admin,代码行数:16,代码来源:Action.php

示例13: actionHandleWebhook

 /**
  * Processing Stripe's callback and making membership updates according to payment data
  *
  * @return void|Response
  */
 public function actionHandleWebhook()
 {
     $payload = json_decode(Yii::$app->request->getRawBody(), true);
     if (!$this->eventExistsOnStripe($payload['id'])) {
         return;
     }
     $method = 'handle' . Inflector::camelize(str_replace('.', '_', $payload['type']));
     if (method_exists($this, $method)) {
         return $this->{$method}($payload);
     } else {
         return $this->missingMethod();
     }
 }
开发者ID:yii2mod,项目名称:yii2-cashier,代码行数:18,代码来源:WebhookController.php

示例14: actionExists

 /**
  * Verify that the action requested is actually an action on the controller
  * @param string $action
  * @return bool
  */
 protected function actionExists($action)
 {
     try {
         $reflection = new \ReflectionClass($this->controller);
         if ($reflection->getMethod('action' . Inflector::camelize($action))) {
             return true;
         }
     } catch (\ReflectionException $e) {
         //method does not exist
         return false;
     }
     return false;
 }
开发者ID:supplyhog,项目名称:yii2-slug-parser,代码行数:18,代码来源:SlugRuleBase.php

示例15: callbackButton

 /**
  * 
  * @param string $value The name/value of the button to display for the user.
  * @param string $callback The id of the callback if the callback method s name is `callbackSayHello` the callback id would be `say-hello`.
  * @param array $params Additional json parameters to send to the callback.
  * @param array $options Define behavior of the button, optionas are name-value pairs. The following options are available:
  * 
  * - closeOnSuccess: boolean, if enabled, the active window will close after successfully sendSuccess() response from callback.
  * - reloadListOnSuccess: boolean, if enabled, the active window will reload the ngrest crud list after success response from callback via sendSuccess().
  * 
  * @return string
  */
 public function callbackButton($value, $callback, array $params = [], array $options = [])
 {
     $json = Json::encode($params);
     $controller = 'Controller' . Inflector::camelize($value) . Inflector::camelize($callback);
     $callback = $this->callbackConvert($callback);
     $closeOnSuccess = null;
     if (isset($options['closeOnSuccess'])) {
         $closeOnSuccess .= '$scope.crud.closeActiveWindow();';
     }
     $reloadListOnSuccess = null;
     if (isset($options['reloadListOnSuccess'])) {
         $reloadListOnSuccess = '$scope.crud.loadList();';
     }
     $return = '<script>
     zaa.bootstrap.register(\'' . $controller . '\', function($scope, $controller) {
         $scope.crud = $scope.$parent;
         $scope.params = ' . $json . ';
         $scope.sendButton = function(callback) {
             $scope.crud.sendActiveWindowCallback(callback, $scope.params).then(function(success) {
                 var data = success.data;
                 var errorType = null;
                 var message = false;
             
                 if ("error" in data) {
                     errorType = data.error;
                 }
             
                 if ("message" in data) {
                     message = data.message;
                 }
             
                 if (errorType !== null) {
                     if (errorType == true) {
                         $scope.crud.toast.error(message, 8000);
                     } else {
                         $scope.crud.toast.success(message, 8000);
                         ' . $closeOnSuccess . $reloadListOnSuccess . '
                     }
                 }
             
 			}, function(error) {
 				$scope.crud.toast.error(error.data.message, 8000);
 			});
         };
     });
     </script>
     <div ng-controller="' . $controller . '">
         <button ng-click="sendButton(\'' . $callback . '\')" class="btn" type="button">' . $value . '</button>
     </div>';
     return $return;
 }
开发者ID:rocksolid-tn,项目名称:luya,代码行数:63,代码来源:ActiveWindowView.php


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