本文整理汇总了PHP中yii\helpers\Inflector::id2camel方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::id2camel方法的具体用法?PHP Inflector::id2camel怎么用?PHP Inflector::id2camel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Inflector
的用法示例。
在下文中一共展示了Inflector::id2camel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$activeWindowHash = Yii::$app->request->get('activeWindowHash');
$activeWindowCallback = Yii::$app->request->get('activeWindowCallback');
$activeWindows = $this->config->getPointer('aw');
$obj = $activeWindows[$activeWindowHash]['object'];
$function = 'callback' . Inflector::id2camel($activeWindowCallback);
return ObjectHelper::callMethodSanitizeArguments($obj, $function, Yii::$app->request->post());
/*
$reflection = new \ReflectionMethod($obj, $function);
$methodArgs = [];
if ($reflection->getNumberOfRequiredParameters() > 0) {
foreach ($reflection->getParameters() as $param) {
if (!array_key_exists($param->name, $args)) {
throw new \Exception("the provided argument '".$param->name."' does not exists in the provided arguments list.");
}
$methodArgs[] = $args[$param->name];
}
}
$response = call_user_func_array(array($obj, $function), $methodArgs);
return $response;
*/
}
示例2: testId2camel
public function testId2camel()
{
$this->assertEquals('PostTag', Inflector::id2camel('post-tag'));
$this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_'));
$this->assertEquals('PostTag', Inflector::id2camel('post-tag'));
$this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_'));
}
示例3: getView
public function getView()
{
if ($this->_view === null) {
$this->_view = lcfirst(Inflector::id2camel($this->id));
}
return $this->_view;
}
示例4: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->action === null) {
$this->action = Inflector::id2camel($this->id);
}
}
示例5: actionIndex
public function actionIndex($callback, $id)
{
$model = NavItemPageBlockItem::findOne($id);
$block = Block::objectId($model->block_id, $model->id, 'callback');
$method = 'callback' . Inflector::id2camel($callback);
return ObjectHelper::callMethodSanitizeArguments($block, $method, Yii::$app->request->get());
}
示例6: search
/**
* Sends a request to the _search API and returns the result.
* @param array $options
* @throws ErrorResponseException
* @return mixed
*/
public function search($options = [])
{
$url = $this->index . Inflector::id2camel(ArrayHelper::remove($options, 'scenario', 'search'));
$query = $this->queryParts;
$options = array_merge($query, $options);
return $this->db->post($url, $options);
}
示例7: getModuleController
/**
* @param \yii\base\Module $module
* @param string $id
*
* @return \yii\base\Controller $controller
*/
public function getModuleController(Module $module, $id)
{
$className = sprintf('%s\\%sController', $module->controllerNamespace, Inflector::id2camel($id));
if (strpos($className, '-') === false && class_exists($className) && is_subclass_of($className, 'yii\\base\\Controller')) {
return new $className($id, $module);
}
return null;
}
示例8: operationName
/**
* Returns name of the operation based on controller's class and it's action name
* @param Controller|string $controller
* @param string $action
* @return string
*/
public static function operationName($controller, $action = '')
{
if (is_object($controller)) {
$controller = $controller->className();
}
/** @var string $controller */
return self::authItemName($controller . ':' . Inflector::id2camel($action));
}
示例9: hasAction
public function hasAction($id, $actions = null)
{
if (is_null($actions)) {
$actions = $this->actions();
}
$method = 'action' . Inflector::id2camel($id);
return isset($actions[$id]) || method_exists($this, $method);
}
示例10: init
public function init()
{
$modelId = Yii::$app->getRequest()->getQueryParam('modelId');
if ($modelId) {
$this->modelName = Inflector::id2camel($modelId);
}
parent::init();
}
示例11: getModelByTableName
public function getModelByTableName($name)
{
$returnName = str_replace($this->tablePrefix, '', $name);
$returnName = Inflector::id2camel($returnName, '_');
if ($this->singularEntities) {
$returnName = Inflector::singularize($returnName);
}
return $returnName;
}
示例12: testId2camel
public function testId2camel()
{
$this->assertEquals('PostTag', Inflector::id2camel('post-tag'));
$this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_'));
$this->assertEquals('PostTag', Inflector::id2camel('post-tag'));
$this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_'));
$this->assertEquals('FooYBar', Inflector::id2camel('foo-y-bar'));
$this->assertEquals('FooYBar', Inflector::id2camel('foo_y_bar', '_'));
}
示例13: __call
/**
* Calls the named method which is not a class method.
* Call this method directly from database connections
*/
public function __call($name, $params)
{
$method = explode('-', Inflector::camel2id($name));
$model = array_shift($method);
$method = lcfirst(Inflector::id2camel(implode('-', $method)));
$class = isset($this->models[$model]) ? $this->models[$model] : null;
if ($class && method_exists($class, $method)) {
return call_user_func_array([$class, $method], $params);
}
$message = 'Calling unknown method: ' . ($class ? $class : get_class($this)) . "::{$name}()";
throw new UnknownMethodException($message);
}
示例14: getAllChild
function getAllChild($role_id, $parent_id = NULL, $level = 0)
{
foreach (\app\models\Menu::find()->where(["parent_id" => $parent_id])->all() as $menu) {
?>
<div class="form-group" style="padding-left: <?php
echo $level * 20;
?>
px">
<label>
<input type="checkbox" name="menu[]" value="<?php
echo $menu->id;
?>
" class="minimal" <?php
echo isChecked($role_id, $menu->id) ? "checked" : "";
?>
>
</label>
<label style="padding-left: 10px"> <?php
echo $menu->name;
?>
</label>
</div>
<?php
//Show All Actions
$camelName = Inflector::id2camel($menu->controller);
$fullControllerName = "app\\controllers\\" . $camelName . "Controller";
if (class_exists($fullControllerName)) {
$reflection = new ReflectionClass($fullControllerName);
$methods = $reflection->getMethods();
echo "<div class=\"form-group\" style=\"padding-left: " . ($level * 20 + 10) . "px;\">";
echo "<label><input type=\"checkbox\" class=\"minimal select-all\" ></label><label style=\"padding: 0px 20px 0px 5px\"> Select All</label>";
foreach ($methods as $method) {
if (substr($method->name, 0, 6) == "action" && $method->name != "actions") {
$camelAction = substr($method->name, 6);
$id = Inflector::camel2id($camelAction);
$name = Inflector::camel2words($camelAction);
$action = \app\models\Action::find()->where(["action_id" => $id, "controller_id" => $menu->controller])->one();
if ($action == NULL) {
//If the action not in database, save it !
$action = new \app\models\Action();
$action->action_id = $id;
$action->controller_id = $menu->controller;
$action->name = $name;
$action->save();
}
showCheckbox("action[]", $action->id, $name, hasAccessToAction($role_id, $action->id));
}
}
echo "</div>";
}
getAllChild($role_id, $menu->id, $level + 1);
}
}
示例15: actionIndex
public function actionIndex($callback, $id)
{
$model = NavItemPageBlockItem::findOne($id);
if (!$model) {
throw new Exception("Unable to find item id.");
}
$block = Block::objectId($model->block_id, $model->id, 'callback');
if (!$block) {
throw new Exception("Unable to find block object.");
}
return ObjectHelper::callMethodSanitizeArguments($block, 'callback' . Inflector::id2camel($callback), Yii::$app->request->get());
}