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


PHP Inflector::classify方法代码示例

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


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

示例1: _class

 /**
  * Get the class name for the mock.
  *
  * @param string $request
  * @return string
  */
 protected function _class($request)
 {
     $name = $request->action;
     $type = $request->command;
     if ($command = $this->_instance($type)) {
         $request->params['action'] = $name;
         $name = $command->invokeMethod('_class', array($request));
     }
     return Inflector::classify("Mock{$name}");
 }
开发者ID:EHER,项目名称:chegamos,代码行数:16,代码来源:Mock.php

示例2: run

 public function run($name = null, $null = null)
 {
     $library = Libraries::get($this->library);
     if (empty($library['prefix'])) {
         return false;
     }
     $model = Inflector::classify($name);
     $use = "\\{$library['prefix']}models\\{$model}";
     $params = array('namespace' => "{$library['prefix']}controllers", 'use' => $use, 'class' => "{$name}Controller", 'model' => $model, 'singular' => Inflector::singularize(Inflector::underscore($name)), 'plural' => Inflector::pluralize(Inflector::underscore($name)));
     if ($this->_save($this->template, $params)) {
         $this->out("{$params['class']} created in {$params['namespace']}.");
         return true;
     }
     return false;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:15,代码来源:Controller.php

示例3: _class

 /**
  * Get the class name for the test case.
  *
  * @param string $request
  * @return string
  */
 protected function _class($request)
 {
     $name = $this->_name($request);
     return Inflector::classify("{$name}Test");
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:11,代码来源:Test.php

示例4: _model

 /**
  * Get the model class used in controller methods.
  *
  * @param string $request
  * @return string
  */
 protected function _model($request)
 {
     return Inflector::classify($request->action);
 }
开发者ID:EHER,项目名称:chegamos,代码行数:10,代码来源:Controller.php

示例5: api

 /**
  * Get the api for the class.
  *
  * @param string $class fully namespaced class in dot notation
  * @param string $type method|property
  * @param string $name the name of the method or property
  * @return array
  */
 public function api($class = null, $type = null, $name = null)
 {
     $class = str_replace(".", "\\", $class);
     switch ($type) {
         default:
             $info = Inspector::info($class);
             $result = array('class' => array('name' => Inflector::classify($info['shortName']), 'description' => $info['description']));
             break;
         case 'method':
             $result = $this->_methods($class, compact('name'));
             break;
         case 'property':
             $result = $this->_properties($class, compact('name'));
             break;
     }
     $this->_render($result);
 }
开发者ID:EHER,项目名称:chegamos,代码行数:25,代码来源:Help.php

示例6: _default

 /**
  * Run through the default set. model, controller, test model, test controller
  *
  * @param string $name class name to create
  * @return boolean
  */
 protected function _default($name)
 {
     $commands = array(array('model', Inflector::classify($name)), array('controller', Inflector::pluralize($name)), array('test', 'model', Inflector::classify($name)), array('test', 'controller', Inflector::pluralize($name)));
     foreach ($commands as $args) {
         $command = $this->template = $this->request->params['command'] = array_shift($args);
         $this->request->params['action'] = array_shift($args);
         $this->request->params['args'] = $args;
         if (!$this->_execute($command)) {
             return false;
         }
     }
     return true;
 }
开发者ID:EHER,项目名称:monopolis,代码行数:19,代码来源:Create.php

示例7: testClassify

 /**
  * testClassNaming method
  *
  * @return void
  */
 public function testClassify()
 {
     $this->assertEqual(Inflector::classify('artists_genres'), 'ArtistsGenre');
     $this->assertEqual(Inflector::classify('file_systems'), 'FileSystem');
     $this->assertEqual(Inflector::classify('news'), 'News');
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:11,代码来源:InflectorTest.php

示例8: resolve

 /**
  * fetches associated records
  *
  * {{{
  *   $post->resolve('user'); // returns user, as defined in $post->user_id
  * }}}
  *
  * @param object $entity current instance
  * @param string|array $fields name of model to load
  * @param array $options an array of options currently supported are
  *              - `resolver` : closure that takes $name as parameter and returns full qualified
  *                 model name.
  *              - `slug` : true or false. If set to true, model is resolving by slug, not by ID.
  *                 The slug has to be saved in a document schema key, named by the singular
  *                 version of the model to reslove.
  * @return array foreign object data
  */
 public function resolve($entity, $fields = null, array $options = array())
 {
     $resolver = function ($name) {
         $modelname = Inflector::pluralize(Inflector::classify($name));
         return Libraries::locate('models', $modelname);
     };
     $slug = false;
     $defaults = compact('resolver', 'slug');
     $options += $defaults;
     switch (true) {
         case is_string($fields) && $options['slug']:
             $fields = array($fields);
             break;
         case is_array($fields) && $options['slug']:
             break;
         case is_string($fields):
             $fields = array(stristr($fields, '_id') ? $fields : "{$fields}_id");
             break;
         case is_array($fields):
             $fields = array_map(function ($field) {
                 return stristr($field, '_id') ? $field : "{$field}_id";
             }, $fields);
             break;
         case empty($fields):
             $fields = self::fields();
             break;
     }
     $result = array();
     foreach ($fields as $field) {
         if (!$options['slug']) {
             if (!preg_match('/^(.+)_id$/', $field, $matches)) {
                 continue;
             }
             list($attribute, $name) = $matches;
         } else {
             $attribute = $field;
             $name = $field;
         }
         $model = $options['resolver']($name);
         if (empty($model)) {
             continue;
         }
         $foreign_id = (string) $entity->{$attribute};
         if (!$foreign_id) {
             continue;
         }
         $result[$name] = $model::load($foreign_id);
     }
     return count($fields) > 1 ? $result : array_shift($result);
 }
开发者ID:bruensicke,项目名称:radium,代码行数:67,代码来源:BaseModel.php

示例9: delete

 /**
  * Generic delete() action.
  * The trick here is that $this->calling_class and $this->calling_method will hold a string
  * reference for which extended class called this delete() method. We need that in order to
  * get the proper records and access.
 */
 public function delete() {
     // get the "_type" ... page_type, user_type, or block_type
     $model = Inflector::classify(Inflector::singularize($this->request->params['controller']));
     $modelClass = 'minerva\models\\'.$model;
     
     $conditions = array();
     if(isset($this->request->params['id'])) {
         $conditions = array('id' => $this->request->params['id']);
     }
     if(isset($this->request->params['url'])) {
         $conditions = array('url' => $this->request->params['url']);
     }
     
     if(empty($conditions)) {
         $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index'));
     }
     
     $document = $this->getDocument(array(
         'action' => __METHOD__,
         'request' => $this->request,
         'find_type' => 'first',
         'conditions' => $conditions
     ));
     
     if($document->delete()) {
         FlashMessage::set('The content has been deleted.', array('options' => array('type' => 'success', 'pnotify_title' => 'Success', 'pnotify_opacity' => .8)));
         $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index'));
     } else {
         FlashMessage::set('The content could not be deleted, please try again.', array('options' => array('type' => 'error', 'pnotify_title' => 'Error', 'pnotify_opacity' => .8)));
         $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index'));
     }
 }
开发者ID:nateabele,项目名称:Minerva-Plugin,代码行数:38,代码来源:MinervaController.php


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