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


PHP camelize函数代码示例

本文整理汇总了PHP中camelize函数的典型用法代码示例。如果您正苦于以下问题:PHP camelize函数的具体用法?PHP camelize怎么用?PHP camelize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: generate

 /**
  * Generates set of code based on data.
  *
  * @return array
  */
 public function generate()
 {
     $this->prepareData($this->data);
     $columnFields = ['name', 'description', 'label'];
     $table = $this->describe->getTable($this->data['name']);
     foreach ($table as $column) {
         if ($column->isAutoIncrement()) {
             continue;
         }
         $field = strtolower($column->getField());
         $method = 'set_' . $field;
         $this->data['camel'][$field] = lcfirst(camelize($method));
         $this->data['underscore'][$field] = underscore($method);
         array_push($this->data['columns'], $field);
         if ($column->isForeignKey()) {
             $referencedTable = Tools::stripTableSchema($column->getReferencedTable());
             $this->data['foreignKeys'][$field] = $referencedTable;
             array_push($this->data['models'], $referencedTable);
             $dropdown = ['list' => plural($referencedTable), 'table' => $referencedTable, 'field' => $field];
             if (!in_array($field, $columnFields)) {
                 $field = $this->describe->getPrimaryKey($referencedTable);
                 $dropdown['field'] = $field;
             }
             array_push($this->data['dropdowns'], $dropdown);
         }
     }
     return $this->data;
 }
开发者ID:rougin,项目名称:combustor,代码行数:33,代码来源:ControllerGenerator.php

示例2: error_messages_for

 public function error_messages_for($object)
 {
     if ($object instanceof WaxForm) {
         if ($object->bound_to_model) {
             if ($object->bound_to_model->errors) {
                 $html = "<ul class='user_errors'>";
             }
             foreach ($object->bound_to_model->errors as $err => $mess) {
                 $html .= "<li>" . $mess[0];
             }
         } else {
             foreach ($object->elements as $el) {
                 foreach ($el->errors as $er) {
                     $html .= sprintf($er->error_template, $er);
                 }
             }
         }
         $html .= "</ul>";
         return $html;
     }
     if (strpos($object, "_")) {
         $object = camelize($object, 1);
     }
     $class = new $object();
     $errors = $class->get_errors();
     foreach ($errors as $error) {
         $html .= $this->content_tag("li", Inflections::humanize($error['field']) . " " . $error['message'], array("class" => "user_error"));
     }
     if (count($errors) > 0) {
         return $this->content_tag("ul", $html, array("class" => "user_errors"));
     }
     return false;
 }
开发者ID:phpwax,项目名称:template,代码行数:33,代码来源:OutputHelper.php

示例3: __call

 function __call($method, $args)
 {
     $sphinx_method = ucfirst(camelize($method));
     if (method_exists($this->client, $sphinx_method)) {
         return call_user_func_array(array($this->client, $sphinx_method), $args);
     }
 }
开发者ID:TheHexa1,项目名称:AMS,代码行数:7,代码来源:sphinxsearch.php

示例4: transformField

 /**
  * Transforms the field into the template.
  *
  * @param  string $field
  * @param  string $type
  * @return array
  */
 protected function transformField($field, $type)
 {
     if ($type == 'camelize') {
         return ['field' => lcfirst(camelize($field)), 'accessor' => lcfirst(camelize('get_' . $field)), 'mutator' => lcfirst(camelize('set_' . $field))];
     }
     return ['field' => lcfirst(underscore($field)), 'accessor' => lcfirst(underscore('get_' . $field)), 'mutator' => lcfirst(underscore('set_' . $field))];
 }
开发者ID:rougin,项目名称:combustor,代码行数:14,代码来源:BaseGenerator.php

示例5: test_camelize

 public function test_camelize()
 {
     $strs = array('this is the string' => 'thisIsTheString', 'this is another one' => 'thisIsAnotherOne', 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'whatDoYouThink-yo?');
     foreach ($strs as $str => $expect) {
         $this->assertEquals($expect, camelize($str));
     }
 }
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:7,代码来源:inflector_helper_test.php

示例6: generateLink

 public static function generateLink($id, $name, $folder)
 {
     $images = array();
     foreach (array(self::IMAGE_ORIGINAL, self::IMAGE_LARGE, self::IMAGE_MEDIUM, self::IMAGE_SMALL, self::IMAGE_THUMB) as $size) {
         $images[camelize(strtolower($size))] = self::createLink($id, $size, $name, $folder);
     }
     return $images;
 }
开发者ID:ramadhanl,项目名称:sia,代码行数:8,代码来源:Image.php

示例7: camelize

 protected function camelize($string)
 {
     if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
         return (string) self::parameters(['string' => DT::STRING])->call(__FUNCTION__)->with($string)->returning(DT::STRING);
     } else {
         return (string) camelize($string);
     }
 }
开发者ID:tfont,项目名称:skyfire,代码行数:8,代码来源:strings.class.php

示例8: sub

 function sub($commands)
 {
     $name = $commands[0];
     $error = new Error();
     $error->command_exists($name);
     $options = getopt(self::SHORTOPTS, self::LONGOPTS);
     $class_name = 'Pgit\\Command\\' . camelize(strtr($name, '-', '_'));
     $instance = new $class_name($commands, $options);
     $instance->run();
 }
开发者ID:curseoff,项目名称:pgit,代码行数:10,代码来源:command.php

示例9: command_exists

 public function command_exists($name)
 {
     $class_name = 'Pgit\\Command\\' . camelize(strtr($name, '-', '_'));
     $filename = \Pgit\Autoloader::load_class_path($class_name);
     if (!file_exists($filename) or !preg_match("#^[a-z\\-]+\$#", $name)) {
         $message = sprintf("pgit: '%s' is not a git command. See 'pgit --help'\n", $name);
         echo $message;
         exit;
     }
 }
开发者ID:curseoff,项目名称:pgit,代码行数:10,代码来源:error.php

示例10: getTableCols

 public function getTableCols()
 {
     $dbCols = \Meta\Db::colInfo($this->table);
     $cols = array();
     foreach ($dbCols as $info) {
         $name = $info->Field;
         // ignore some fields
         if (in_array($name, array('password'))) {
             continue;
         }
         $cols[$info->Field] = $this->getColType($info, array('id' => $name, 'label' => camelize($info->Field)));
     }
     return $cols;
 }
开发者ID:moiseh,项目名称:codegen,代码行数:14,代码来源:Crud.php

示例11: getTableFields

 public function getTableFields()
 {
     $dbCols = \Meta\Db::colInfo($this->table);
     $fields = array();
     foreach ($dbCols as $info) {
         $name = $info->Field;
         // ignore some fields
         if (in_array($name, array('password'))) {
             continue;
         }
         $fields[$info->Field] = $this->getFieldType($info, array('name' => $name, 'label' => camelize($info->Field), 'isRequired' => $info->Null == 'NO'));
     }
     return $fields;
 }
开发者ID:moiseh,项目名称:codegen,代码行数:14,代码来源:Crud.php

示例12: prepareData

 /**
  * Prepares the data before generation.
  *
  * @param  array $data
  * @return void
  */
 public function prepareData(array &$data)
 {
     $bootstrap = ['button' => 'btn btn-default', 'buttonPrimary' => 'btn btn-primary', 'formControl' => 'form-control', 'formGroup' => 'form-group col-lg-12 col-md-12 col-sm-12 col-xs-12', 'label' => 'control-label', 'table' => 'table table table-striped table-hover', 'textRight' => 'text-right'];
     if ($data['isBootstrap']) {
         $data['bootstrap'] = $bootstrap;
     }
     $data['camel'] = [];
     $data['underscore'] = [];
     $data['foreignKeys'] = [];
     $data['primaryKeys'] = [];
     $data['plural'] = plural($data['name']);
     $data['singular'] = singular($data['name']);
     $primaryKey = 'get_' . $this->describe->getPrimaryKey($data['name']);
     $data['primaryKey'] = $primaryKey;
     if ($this->data['isCamel']) {
         $data['primaryKey'] = camelize($data['primaryKey']);
     }
     $data['columns'] = $this->describe->getTable($data['name']);
 }
开发者ID:rougin,项目名称:combustor,代码行数:25,代码来源:ViewGenerator.php

示例13: get_adapter

 /**
  * Loads and returns a db adapter instance.
  */
 static function get_adapter($name, $params)
 {
     // Adapter class name convention.
     $adapter_class = camelize($name) . 'Database';
     // Try to load adapter class.
     if (!class_exists($adapter_class)) {
         $adapter_file = APP_ROOT . "core/library/db/{$adapter_class}.php";
         if (is_file($adapter_file)) {
             require_once $adapter_file;
         }
     }
     // Instantiate the adapter.
     $adapter = new $adapter_class($params);
     // Make sure it extends Database.
     if ($adapter instanceof Database == false) {
         throw new Exception("{$name} is not a valid database adapter ({$adapter_class})");
     }
     return $adapter;
 }
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:22,代码来源:Database.php

示例14: _run_middlewares

 protected function _run_middlewares()
 {
     $this->load->helper('inflector');
     $middlewares = $this->middleware();
     foreach ($middlewares as $middleware) {
         $middlewareArray = explode('|', str_replace(' ', '', $middleware));
         $middlewareName = $middlewareArray[0];
         $runMiddleware = true;
         if (isset($middlewareArray[1])) {
             $options = explode(':', $middlewareArray[1]);
             $type = $options[0];
             $methods = explode(',', $options[1]);
             if ($type == 'except') {
                 if (in_array($this->router->method, $methods)) {
                     $runMiddleware = false;
                 }
             } else {
                 if ($type == 'only') {
                     if (!in_array($this->router->method, $methods)) {
                         $runMiddleware = false;
                     }
                 }
             }
         }
         $filename = ucfirst(camelize($middlewareName)) . 'Middleware';
         if ($runMiddleware == true) {
             if (file_exists(APPPATH . 'middlewares/' . $filename . '.php')) {
                 require APPPATH . 'middlewares/' . $filename . '.php';
                 $ci =& get_instance();
                 $object = new $filename($this, $ci);
                 $object->run();
                 $this->middlewares[$middlewareName] = $object;
             } else {
                 if (ENVIRONMENT == 'development') {
                     show_error('Unable to load middleware: ' . $filename . '.php');
                 } else {
                     show_error('Sorry something went wrong.');
                 }
             }
         }
     }
 }
开发者ID:SIJOT,项目名称:SIJOT-1.x,代码行数:42,代码来源:MY_Controller.php

示例15: delete_model

 function delete_model($name)
 {
     $results = array();
     $name = singularize($name);
     $uploader_class_suffix = 'ImageUploader';
     $image_uploader_class_suffix = 'ImageUploader';
     $file_uploader_class_suffix = 'FileUploader';
     $uploaders_path = FCPATH . 'application/third_party/orm_uploaders/';
     $model_path = FCPATH . 'application/models/' . ucfirst(camelize($name)) . EXT;
     $content = read_file($model_path);
     preg_match_all('/OrmImageUploader::bind\\s*\\((?P<k>.*)\\);/', $content, $image_uploaders);
     $image_uploaders = array_map(function ($image_uploader) use($name, $image_uploader_class_suffix) {
         return isset($image_uploader[1]) ? $image_uploader[1] : ucfirst(camelize($name)) . $image_uploader_class_suffix;
     }, array_map(function ($image_uploader) {
         $pattern = '/(["\'])(?P<kv>(?>[^"\'\\\\]++|\\\\.|(?!\\1)["\'])*)\\1?/';
         preg_match_all($pattern, $image_uploader, $image_uploaders);
         return $image_uploaders['kv'];
     }, $image_uploaders['k']));
     array_map(function ($image_uploader) use($uploaders_path, &$results) {
         if (delete_file($uploaders_path . $image_uploader . EXT)) {
             array_push($results, $uploaders_path . $image_uploader . EXT);
         }
     }, $image_uploaders);
     preg_match_all('/OrmFileUploader::bind\\s*\\((?P<k>.*)\\);/', $content, $file_uploaders);
     $file_uploaders = array_map(function ($file_uploader) use($name, $file_uploader_class_suffix) {
         return isset($file_uploader[1]) ? $file_uploader[1] : ucfirst(camelize($name)) . $file_uploader_class_suffix;
     }, array_map(function ($file_uploader) {
         $pattern = '/(["\'])(?P<kv>(?>[^"\'\\\\]++|\\\\.|(?!\\1)["\'])*)\\1?/';
         preg_match_all($pattern, $file_uploader, $file_uploaders);
         return $file_uploaders['kv'];
     }, $file_uploaders['k']));
     array_map(function ($file_uploader) use($uploaders_path, &$results) {
         if (delete_file($uploaders_path . $file_uploader . EXT)) {
             array_push($results, $uploaders_path . $file_uploader . EXT);
         }
     }, $file_uploaders);
     if (delete_file($model_path)) {
         array_push($results, $model_path);
     }
     return $results;
 }
开发者ID:javidhsueh,项目名称:weather,代码行数:41,代码来源:delete.php


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