當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inflector::getInstance方法代碼示例

本文整理匯總了PHP中Inflector::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::getInstance方法的具體用法?PHP Inflector::getInstance怎麽用?PHP Inflector::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inflector的用法示例。


在下文中一共展示了Inflector::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: forward

 /**
  * Enter description here...
  *
  * @return unknown
  */
 function forward()
 {
     $_this =& AmfDispatcher::getInstance();
     $_this->parse();
     if ($_this->input !== null) {
         $target = null;
         $Inflector =& Inflector::getInstance();
         $_this->requests = count($_this->bodies);
         for ($i = 0; $i < $_this->requests; $i++) {
             $_this->request++;
             if (isset($_this->headers[$i])) {
                 $_this->header = $_this->headers[$i];
             }
             $_this->body = $_this->bodies[$i];
             unset($_this->bodies[$i]);
             if (isset($_this->body['target'])) {
                 $target = $_this->body['target'];
             }
             $_this->__dispatch($target);
         }
         exit;
     }
     return false;
 }
開發者ID:BGCX067,項目名稱:fake-as3-svn-to-git,代碼行數:29,代碼來源:amf_dispatcher.php

示例2: underscore

 public function underscore($camelCasedWord)
 {
     $_this =& Inflector::getInstance();
     if (!($result = $_this->_cache(__FUNCTION__, $camelCasedWord))) {
         $result = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
         $_this->_cache(__FUNCTION__, $camelCasedWord, $result);
     }
     return $result;
 }
開發者ID:hracsi,項目名稱:HMVC,代碼行數:9,代碼來源:inflector.php

示例3: slug

 /**
  * Returns a string with all spaces converted to underscores (by default), accented
  * characters converted to non-accented characters, and non word characters removed.
  *
  * @param string $string the string you want to slug
  * @param string $replacement will replace keys in map
  * @param array $map extra elements to map to the replacement
  * @deprecated $map param will be removed in future versions. Use Inflector::rules() instead
  * @return string
  * @access public
  * @static
  * @link http://book.cakephp.org/view/1479/Class-methods
  */
 function slug($string, $replacement = '_', $map = array())
 {
     $_this =& Inflector::getInstance();
     if (is_array($replacement)) {
         $map = $replacement;
         $replacement = '_';
     }
     $quotedReplacement = preg_quote($replacement, '/');
     $merge = array('/[^\\s\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nd}]/mu' => ' ', '/\\s+/' => $replacement, sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '');
     $map = $map + $_this->_transliteration + $merge;
     return preg_replace(array_keys($map), array_values($map), $string);
 }
開發者ID:EverettQuebral,項目名稱:LocaleMaps,代碼行數:25,代碼來源:inflector.php

示例4: __connectDefaultRoutes

 /**
  * Connects the default, built-in routes, including admin routes, and (deprecated) web services
  * routes.
  *
  * @access private
  */
 function __connectDefaultRoutes()
 {
     $_this =& Router::getInstance();
     if ($_this->__defaultsMapped) {
         return;
     }
     if ($admin = Configure::read('Routing.admin')) {
         $params = array('prefix' => $admin, $admin => true);
     }
     if ($plugins = Configure::listObjects('plugin')) {
         $Inflector =& Inflector::getInstance();
         $plugins = array_map(array(&$Inflector, 'underscore'), $plugins);
     }
     if (!empty($plugins)) {
         $match = array('plugin' => implode('|', $plugins));
         $_this->connect('/:plugin/:controller/:action/*', array(), $match);
         if ($admin) {
             $_this->connect("/{$admin}/:plugin/:controller", $params, $match);
             $_this->connect("/{$admin}/:plugin/:controller/:action/*", $params, $match);
         }
     }
     if ($admin) {
         $_this->connect("/{$admin}/:controller", $params);
         $_this->connect("/{$admin}/:controller/:action/*", $params);
     }
     $_this->connect('/:controller', array('action' => 'index'));
     $_this->connect('/:controller/:action/*');
     if ($_this->named['rules'] === false) {
         $_this->connectNamed(true);
     }
     $_this->__defaultsMapped = true;
 }
開發者ID:BLisa90,項目名稱:cakecart,代碼行數:38,代碼來源:router.php

示例5: getCollection

 /**
  * Get the collection for this class
  *
  * @return MongoCollection
  * @throws Exception
  */
 protected static function getCollection()
 {
     $className = get_called_class();
     if (null !== static::$collectionName) {
         $collectionName = static::$collectionName;
     } else {
         $collectionName = explode('\\', $className);
         $collectionName = end($collectionName);
         $inflector = Inflector::getInstance();
         $collectionName = $inflector->tableize($collectionName);
     }
     if ($className::$database == null) {
         throw new Exception("BaseMongoRecord::database must be initialized to a proper database string");
     }
     if ($className::$connection == null) {
         throw new Exception("BaseMongoRecord::connection must be initialized to a valid Mongo object");
     }
     if (!$className::$connection->connected) {
         $className::$connection->connect();
     }
     return $className::$connection->selectCollection($className::$database, $collectionName);
 }
開發者ID:caseyamcl,項目名稱:mongorecord,代碼行數:28,代碼來源:BaseMongoRecord.php

示例6: setUp

 /**
  * setUp method
  * 
  * @access public
  * @return void
  */
 function setUp()
 {
     $this->Inflector = Inflector::getInstance();
 }
開發者ID:subh,項目名稱:raleigh-workshop-08,代碼行數:10,代碼來源:inflector.test.php

示例7: __connectDefaultRoutes

 /**
  * Connects the default, built-in routes, including admin routes, and (deprecated) web services
  * routes.
  *
  * @access private
  */
 function __connectDefaultRoutes()
 {
     $_this =& Router::getInstance();
     if ($_this->__defaultsMapped) {
         return;
     }
     if ($admin = Configure::read('Routing.admin')) {
         $params = array('prefix' => $admin, $admin => true);
     }
     $Inflector =& Inflector::getInstance();
     $plugins = array_map(array(&$Inflector, 'underscore'), Configure::listObjects('plugin'));
     if (!empty($plugins)) {
         $match = array('plugin' => implode('|', $plugins));
         $_this->connect('/:plugin/:controller/:action/*', array(), $match);
         if ($admin) {
             $_this->connect("/{$admin}/:plugin/:controller", $params, $match);
             $_this->connect("/{$admin}/:plugin/:controller/:action/*", $params, $match);
         }
     }
     if ($admin) {
         $_this->connect("/{$admin}/:controller", $params);
         $_this->connect("/{$admin}/:controller/:action/*", $params);
     }
     $_this->connect('/:controller', array('action' => 'index'));
     /**
      * Deprecated
      *
      */
     $_this->connect('/bare/:controller/:action/*', array('bare' => '1'));
     $_this->connect('/ajax/:controller/:action/*', array('bare' => '1'));
     if (Configure::read('Routing.webservices') == 'on') {
         trigger_error('Deprecated: webservices routes are deprecated and will not be supported in future versions.  Use Router::parseExtensions() instead.', E_USER_WARNING);
         $_this->connect('/rest/:controller/:action/*', array('webservices' => 'Rest'));
         $_this->connect('/rss/:controller/:action/*', array('webservices' => 'Rss'));
         $_this->connect('/soap/:controller/:action/*', array('webservices' => 'Soap'));
         $_this->connect('/xml/:controller/:action/*', array('webservices' => 'Xml'));
         $_this->connect('/xmlrpc/:controller/:action/*', array('webservices' => 'XmlRpc'));
     }
     $_this->connect('/:controller/:action/*');
     if (empty($_this->__namedArgs)) {
         $_this->connectNamed(array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'));
     }
     $_this->__defaultsMapped = true;
 }
開發者ID:kaz0636,項目名稱:openflp,代碼行數:50,代碼來源:router.php

示例8: listObjects

 /**
  * Returns an index of objects of the given type, with the physical path to each object
  *
  * @param string	$type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin'
  * @param mixed		$path Optional
  * @return Configure instance
  * @access public
  */
 function listObjects($type, $path = null, $cache = true)
 {
     $_this =& Configure::getInstance();
     $objects = array();
     $extension = false;
     $name = $type;
     if ($type === 'file' && !$path) {
         return false;
     } elseif ($type === 'file') {
         $extension = true;
         $name = $type . str_replace(DS, '', $path);
     }
     if (empty($_this->__objects) && $cache === true) {
         $_this->__objects = Cache::read('object_map', '_cake_core_');
     }
     if (empty($_this->__objects) || !isset($_this->__objects[$type]) || $cache !== true) {
         $Inflector =& Inflector::getInstance();
         $types = array('model' => array('suffix' => '.php', 'base' => 'AppModel', 'core' => false), 'behavior' => array('suffix' => '.php', 'base' => 'ModelBehavior'), 'controller' => array('suffix' => '_controller.php', 'base' => 'AppController'), 'component' => array('suffix' => '.php', 'base' => null), 'view' => array('suffix' => '.php', 'base' => null), 'helper' => array('suffix' => '.php', 'base' => 'AppHelper'), 'plugin' => array('suffix' => '', 'base' => null), 'vendor' => array('suffix' => '', 'base' => null), 'class' => array('suffix' => '.php', 'base' => null), 'file' => array('suffix' => '.php', 'base' => null));
         if (!isset($types[$type])) {
             return false;
         }
         $objects = array();
         if (empty($path)) {
             $path = $_this->{$type . 'Paths'};
             if (isset($types[$type]['core']) && $types[$type]['core'] === false) {
                 array_pop($path);
             }
         }
         $items = array();
         foreach ((array) $path as $dir) {
             if ($type === 'file' || $type === 'class' || strpos($dir, $type) !== false) {
                 $items = $_this->__list($dir, $types[$type]['suffix'], $extension);
                 $objects = array_merge($items, array_diff($objects, $items));
             }
         }
         if ($type !== 'file') {
             $objects = array_map(array(&$Inflector, 'camelize'), $objects);
         }
         if ($cache === true) {
             $_this->__objects[$name] = $objects;
             $_this->__cache = true;
         } else {
             return $objects;
         }
     }
     return $_this->__objects[$name];
 }
開發者ID:BLisa90,項目名稱:cakecart,代碼行數:55,代碼來源:configure.php

示例9: has_many

 /**
  * has_many
  * @param mix
  * @return void
  * @comment generate getter/setter for array of target class
  */
 protected function has_many()
 {
     $numcls = func_num_args();
     $cls_list = func_get_args();
     $inflector = Inflector::getInstance();
     $self = $this;
     foreach ($cls_list as $clsname) {
         $plurclsname = $inflector->pluralize($clsname);
         //add,create,remove
         $funcname = "add{$clsname}";
         $this->addfunc($funcname, function ($item) use($clsname, $self) {
             $id = $item->getID();
             if ($id == null) {
                 //if id is null then recall the func after save
                 $item->afterSave_once = function () use($item, $self, $clsname) {
                     $addx = "add{$clsname}";
                     $self->{$addx}($item);
                 };
                 return $self;
             }
             $getx = "get{$clsname}ids";
             $itemids = $self->{$getx}();
             if ($itemids == null) {
                 $itemids = array();
             }
             array_push($itemids, $item->getID());
             $setx = "set{$clsname}ids";
             $self->{$setx}($itemids);
             return $self;
         });
         $funcname = "create{$clsname}";
         $this->addfunc($funcname, function () use($clsname, $self) {
             $item = new $clsname();
             $addx = "add{$clsname}";
             $self->{$addx}($item);
             return $item;
         });
         $funcname = "remove{$clsname}";
         $this->addfunc($funcname, function ($item) use($clsname, $self) {
             $getx = "get{$clsname}ids";
             $itemids = $self->{$getx}();
             $key = array_search($item->getID(), $itemids);
             if (gettype($key) == "boolean") {
                 //no such value
                 return $self;
             }
             unset($itemids[$key]);
             //remove the id
             $setx = "set{$clsname}ids";
             $self->{$setx}($itemids);
             return $self;
         });
         $funcname = "get{$plurclsname}";
         $this->addfunc($funcname, function () use($clsname, $self) {
             $getx = "get{$clsname}ids";
             $itemids = $self->{$getx}();
             $items = $clsname::find(array('_id' => array('$in' => $itemids)));
             return $items;
             //return MongoRecordIterator
         });
         $funcname = "set{$plurclsname}";
         $this->addfunc($funcname, function ($items) use($clsname, $self) {
             $itemids = array();
             foreach ($items as $item) {
                 array_push($itemids, $item->getID());
             }
             if (count($itemids) == 0) {
                 return $self;
             }
             $setx = "set{$clsname}ids";
             $self->{$setx}($itemids);
             return $self;
         });
     }
 }
開發者ID:poovarasanvasudevan,項目名稱:MongoRecord,代碼行數:81,代碼來源:BaseMongoRecord.php

示例10: getAllModels

 function getAllModels()
 {
     $Inflector =& Inflector::getInstance();
     uses('Folder');
     $folder = new Folder(MODELS);
     $models = $folder->findRecursive('.*php');
     $folder = new Folder(BEHAVIORS);
     $behaviors = $folder->findRecursive('.*php');
     $models = array_diff($models, $behaviors);
     foreach ($models as $id => $model) {
         $file = new File($model);
         $models[$id] = $file->name();
     }
     $models = array_map(array(&$Inflector, 'camelize'), $models);
     App::import('Model', $models);
     return $models;
 }
開發者ID:vad,項目名稱:taolin,代碼行數:17,代碼來源:visualize.php

示例11: tableize

/**
 * tableize
 * 
 * takes a (CamelCase or not) name ('DbSession')
 * makes it lower_case and plural ('db_sessions')
 * this implementation is just stupid and needs replacing
 * 
 * @access public
 * @param string $table
 * @return string
 */
function tableize($object)
{
    $inflector =& Inflector::getInstance();
    return $inflector->tableize($object);
}
開發者ID:voitto,項目名稱:dbscript,代碼行數:16,代碼來源:_functions.php

示例12: groups

 /**
  * undocumented function
  *
  * @param string $key
  * @return void
  */
 function groups($key = null)
 {
     $result = array();
     if (!empty($this->current['config']['groups'])) {
         $groups = array_map('trim', explode(',', $this->current['config']['groups']));
         $Inflector = Inflector::getInstance();
         $groups = array_map(array($Inflector, 'slug'), $groups, array_fill(0, count($groups), '-'));
         $result = array_combine($groups, $groups);
     }
     if (!isset($result['admin'])) {
         $result['admin'] = 'admin';
     }
     if (!isset($result['user'])) {
         $result['user'] = 'user';
     }
     arsort($result);
     return $result;
 }
開發者ID:Theaxiom,項目名稱:chaw-source,代碼行數:24,代碼來源:project.php

示例13: dirname

<?php

/**
 * Arquivo para adaptação da aplicação para Português-Brasil
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @author        Juan Basso <jrbasso@gmail.com>
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
// Definindo idioma da aplicação
Configure::write('Config.language', 'pt-br');
// Adicionando o caminho do locale
$localePaths = Configure::read('localePaths');
$localePaths[] = dirname(dirname(__FILE__)) . DS . 'locale';
Configure::write('localePaths', $localePaths);
// Alteração do inflection
require dirname(__FILE__) . DS . 'inflections.php';
$inflector = Inflector::getInstance();
$inflector->__pluralRules = $pluralRules;
$inflector->__uninflectedPlural = $uninflectedPlural;
$inflector->__irregularPlural = $irregularPlural;
$inflector->__singularRules = $singularRules;
$inflector->__uninflectedSingular = $uninflectedPlural;
$inflector->__irregularSingular = array_flip($irregularPlural);
開發者ID:edubress,項目名稱:cake_ptbr,代碼行數:27,代碼來源:bootstrap.php

示例14: variable

 /**
  * Returns camelBacked version of an underscored string.
  *
  * @param string $string
  * @return string in variable form
  * @access public
  * @static
  * @link http://book.cakephp.org/view/572/Class-methods
  */
 function variable($string)
 {
     $_this = Inflector::getInstance();
     if (!($result = $_this->_cache(__FUNCTION__, $string))) {
         $string2 = Inflector::camelize(Inflector::underscore($string));
         $replace = strtolower(substr($string2, 0, 1));
         $result = preg_replace('/\\w/', $replace, $string2, 1);
         $_this->_cache(__FUNCTION__, $string, $result);
     }
     return $result;
 }
開發者ID:santhoshanand,項目名稱:cranium-crm,代碼行數:20,代碼來源:Inflector.php

示例15: testInstantiation

 /**
  * testInstantiation method
  *
  * @access public
  * @return void
  */
 function testInstantiation()
 {
     $this->skipUnless(strpos(Debugger::trace(), 'GroupTest') === false, '%s Cannot be run from within a group test');
     $Instance = Inflector::getInstance();
     $this->assertEqual(new Inflector(), $Instance);
 }
開發者ID:adaptivertc,項目名稱:mosat,代碼行數:12,代碼來源:inflector.test.php


注:本文中的Inflector::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。