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


PHP Str::classify方法代码示例

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


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

示例1: structure

 protected function structure()
 {
     foreach (new FilesystemIterator($this->migrationPath()) as $file) {
         $migration = basename($file->getFileName(), '.php');
         $this->log('Install ' . $migration . '...');
         $class = 'FluxBB_Install_' . Str::classify($migration);
         include_once $file;
         $instance = new $class();
         $instance->up();
     }
 }
开发者ID:imihael,项目名称:fluxbb-core,代码行数:11,代码来源:Install.php

示例2: _view_generation

 /**
  * This method is responsible for generation all
  * source from the templates, and populating the
  * files array.
  *
  * @return void
  */
 private function _view_generation()
 {
     $prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
     $view_prefix = $this->bundle == DEFAULT_BUNDLE ? '' : $this->bundle . '::';
     // set up the markers for replacement within source
     $markers = array('#LOWERFULL#' => $view_prefix . Str::lower(str_replace('/', '.', $this->class_path) . $this->lower));
     // loud our view template
     $template = Common::load_template('view/view.tpl');
     // added the file to be created
     $this->writer->create_file('View', $this->class_path . $this->lower . EXT, $this->bundle_path . 'views/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
 }
开发者ID:niceboy120,项目名称:Music-Platform,代码行数:18,代码来源:view.php

示例3: _model_generation

 /**
  * This method is responsible for generation all
  * source from the templates, and populating the
  * files array.
  *
  * @return void
  */
 private function _model_generation()
 {
     $prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
     // set up the markers for replacement within source
     $markers = array('#CLASS#' => $prefix . $this->class_prefix . $this->class, '#LOWER#' => $this->lower, '#TIMESTAMPS#' => $this->_timestamps);
     // loud our model template
     $template = Common::load_template('model/model.tpl');
     // holder for relationships source
     $relationships_source = '';
     // loop through our relationships
     foreach ($this->arguments as $relation) {
         // if we have a valid relation
         if (!strstr($relation, ':')) {
             continue;
         }
         // split
         $relation_parts = explode(':', Str::lower($relation));
         // we need two parts
         if (!count($relation_parts) == 2) {
             continue;
         }
         // markers for relationships
         $rel_markers = array('#SINGULAR#' => Str::lower(Str::singular($relation_parts[1])), '#PLURAL#' => Str::lower(Str::plural($relation_parts[1])), '#WORD#' => Str::classify(Str::singular($relation_parts[1])), '#WORDS#' => Str::classify(Str::plural($relation_parts[1])));
         // start with blank
         $relationship_template = '';
         // use switch to decide which template
         switch ($relation_parts[0]) {
             case "has_many":
             case "hm":
                 $relationship_template = Common::load_template('model/has_many.tpl');
                 break;
             case "belongs_to":
             case "bt":
                 $relationship_template = Common::load_template('model/belongs_to.tpl');
                 break;
             case "has_one":
             case "ho":
                 $relationship_template = Common::load_template('model/has_one.tpl');
                 break;
             case "has_and_belongs_to_many":
             case "hbm":
                 $relationship_template = Common::load_template('model/has_and_belongs_to_many.tpl');
                 break;
         }
         // add it to the source
         $relationships_source .= Common::replace_markers($rel_markers, $relationship_template);
     }
     // add a marker to replace the relationships stub
     // in the model template
     $markers['#RELATIONS#'] = $relationships_source;
     // add the generated model to the writer
     $this->writer->create_file('Model', $prefix . $this->class_prefix . $this->class, $this->bundle_path . 'models/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
 }
开发者ID:downleave,项目名称:blog,代码行数:60,代码来源:model.php

示例4: _controller_generation

 /**
  * This method is responsible for generation all
  * source from the templates, and populating the
  * files array.
  *
  * @return void
  */
 private function _controller_generation()
 {
     $prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
     $view_prefix = $this->bundle == DEFAULT_BUNDLE ? '' : $this->bundle . '::';
     // set up the markers for replacement within source
     $markers = array('#CLASS#' => $prefix . $this->class_prefix . $this->class, '#LOWER#' => $this->lower, '#LOWERFULL#' => $view_prefix . Str::lower(str_replace('/', '.', $this->class_path) . $this->lower));
     // loud our controller template
     $template = Common::load_template('controller/controller.tpl');
     // holder for actions source, and base templates for actions and views
     $actions_source = '';
     $action_template = Common::load_template('controller/action.tpl');
     $view_template = Common::load_template('controller/view.tpl');
     $restful = strstr(implode(' ', $this->arguments), ':') ? true : false;
     array_unshift($this->arguments, 'index');
     // loop through our actions
     foreach ($this->arguments as $action) {
         $verb = $restful ? 'get' : 'action';
         if (strstr($action, ':')) {
             $parts = explode(':', $action);
             if (count($parts) == 2) {
                 $verb = Str::lower($parts[0]);
                 $action = Str::lower($parts[1]);
             }
         }
         // add the current action to the markers
         $markers['#ACTION#'] = Str::lower($action);
         $markers['#VERB#'] = $verb;
         // append the replaces source
         $actions_source .= Common::replace_markers($markers, $action_template);
         $file_prefix = $restful ? $verb . '_' : '';
         // add the file to be created
         $this->writer->create_file('View', $this->class_path . $this->lower . '/' . $file_prefix . Str::lower($action) . $this->_view_extension, $this->bundle_path . 'views/' . $this->class_path . $this->lower . '/' . $file_prefix . Str::lower($action) . $this->_view_extension, Common::replace_markers($markers, $view_template));
     }
     // add a marker to replace the actions stub in the controller
     // template
     $markers['#ACTIONS#'] = $actions_source;
     $markers['#RESTFUL#'] = $restful ? "\n\tpublic \$restful = true;\n" : '';
     // added the file to be created
     $this->writer->create_file('Controller', $markers['#CLASS#'] . '_Controller', $this->bundle_path . 'controllers/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
     $this->writer->append_to_file($this->bundle_path . 'routes.php', "\n\n// Route for {$markers['#CLASS#']}_Controller\nRoute::controller('{$markers['#LOWERFULL#']}');");
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:48,代码来源:controller.php

示例5: _config_generation

 /**
  * This method is responsible for generation all
  * source from the templates, and populating the
  * files array.
  *
  * @return void
  */
 private function _config_generation()
 {
     $prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
     $view_prefix = $this->bundle == DEFAULT_BUNDLE ? '' : $this->bundle . '::';
     // loud our config template
     $template = Common::load_template('config/config.tpl');
     // holder for options source, and base template for options
     $options_source = '';
     $option_template = Common::load_template('config/option.tpl');
     // loop through our options
     foreach ($this->arguments as $option) {
         // add the current option to the markers
         $markers['#OPTION#'] = Str::lower($option);
         // append the replaces source
         $options_source .= Common::replace_markers($markers, $option_template);
     }
     // add a marker to replace the options stub in the config
     // template
     $markers['#OPTIONS#'] = $options_source;
     // added the file to be created
     $this->writer->create_file('Config', $this->lower . EXT, $this->bundle_path . 'config/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:29,代码来源:config.php

示例6: _task_generation

 /**
  * This method is responsible for generation all
  * source from the templates, and populating the
  * files array.
  *
  * @return void
  */
 private function _task_generation()
 {
     $prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
     $view_prefix = $this->bundle == DEFAULT_BUNDLE ? '' : $this->bundle . '::';
     // set up the markers for replacement within source
     $markers = array('#CLASS#' => $prefix . $this->class_prefix . $this->class, '#LOWER#' => $this->lower, '#LOWERFULL#' => $view_prefix . Str::lower(str_replace('/', '.', $this->class_path) . $this->lower));
     // loud our task template
     $template = Common::load_template('task/task.tpl');
     // holder for methods source, and base template for methods
     $methods_source = '';
     $method_template = Common::load_template('task/method.tpl');
     // loop through our methods
     foreach ($this->arguments as $method) {
         // add the current method to the markers
         $markers['#METHOD#'] = Str::lower($method);
         // append the replaces source
         $methods_source .= Common::replace_markers($markers, $method_template);
     }
     // add a marker to replace the methods stub in the task
     // template
     $markers['#METHODS#'] = $methods_source;
     // added the file to be created
     $this->writer->create_file('Task', $markers['#CLASS#'] . '_Task', $this->bundle_path . 'tasks/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:31,代码来源:task.php

示例7: __construct

 /**
  * Determine class names, identifiers and arguments based on the args
  * passed by the build script.
  *
  * @param array Arguments to the build script.
  * @return void
  */
 public function __construct($args)
 {
     // we need a writer object for file system changes
     $this->writer = new Writer();
     // set default args
     $this->args = $args;
     // if we got an argument
     if (isset($args[0])) {
         // check to see if its bundle prefixed
         if (strstr($args[0], '::')) {
             $parts = explode('::', $args[0]);
             // if we have a bundle and a class
             if (count($parts) == 2 && $parts[0] !== '') {
                 $this->bundle = Str::lower($parts[0]);
                 if (!Bundle::exists($this->bundle)) {
                     Common::error('The specified bundle does not exist, or is not loaded.');
                 }
                 // remove the bundle section, we are done with that
                 $args[0] = $parts[1];
             }
         } else {
             // use the application folder if no bundle
             $this->bundle = DEFAULT_BUNDLE;
         }
         // set bundle path from bundle name
         $this->bundle_path = Bundle::path($this->bundle);
         // if we have a multi-level path
         if (strstr($args[0], '.')) {
             $parts = explode('.', $args[0]);
             // form the class prefix as in Folder_Folder_Folder_
             $this->class_prefix = Str::classify(implode('_', array_slice($parts, 0, -1)) . '_');
             // form the path to the class
             $this->class_path = Str::lower(implode('/', array_slice($parts, 0, -1)) . '/');
             // unaltered case class
             $this->standard = $parts[count($parts) - 1];
             // lowercase class
             $this->lower = Str::lower($parts[count($parts) - 1]);
             // get our class name
             $this->class = Str::classify($parts[count($parts) - 1]);
         } else {
             // unaltered case class
             $this->standard = $args[0];
             // lowercase class
             $this->lower = Str::lower($args[0]);
             // get our class name
             $this->class = Str::classify($args[0]);
         }
     }
     // pass remaining arguments
     $this->arguments = array_slice($args, 1);
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:58,代码来源:generator.php

示例8: testStringsCanBeClassified

 /**
  * Test the Str::classify method.
  *
  * @group laravel
  */
 public function testStringsCanBeClassified()
 {
     $this->assertEquals('Something_Else', Str::classify('something.else'));
     $this->assertEquals('Something_Else', Str::classify('something_else'));
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:10,代码来源:str.test.php


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