本文整理匯總了PHP中Inflector::uncamelize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::uncamelize方法的具體用法?PHP Inflector::uncamelize怎麽用?PHP Inflector::uncamelize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::uncamelize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __call
public function __call($m, $a)
{
if (fnmatch('set*', $m)) {
$k = Inflector::lower(Inflector::uncamelize(lcfirst(substr($m, 3))));
$v = empty($a) ? true : current($a);
self::$__events[$this->__ns][$k] = $v;
return $this;
} elseif (fnmatch('get*', $m)) {
$k = Inflector::lower(Inflector::uncamelize(lcfirst(substr($m, 3))));
if (isset(self::$__events[$this->__ns][$k])) {
return self::$__events[$this->__ns][$k];
}
$default = empty($a) ? null : current($args);
return $default;
} elseif (fnmatch('has*', $m)) {
$k = Inflector::lower(Inflector::uncamelize(lcfirst(substr($m, 3))));
return isset(self::$__events[$this->__ns][$k]);
} elseif (fnmatch('clear*', $m)) {
$k = Inflector::lower(Inflector::uncamelize(lcfirst(substr($m, 5))));
unset(self::$__events[$this->__ns][$k]);
return $this;
} else {
if (isset(self::$__events[$this->__ns][$m])) {
$v = self::$__events[$this->__ns][$m];
if (is_callable($v)) {
return call_user_func_array($v, $a);
} else {
return $v;
}
}
}
}
示例2: __call
public function __call($func, $argv)
{
if (substr($func, 0, 3) == 'get') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
$key = Inflector::lower($uncamelizeMethod);
if (isset($argv[0])) {
$environment = $argv[0];
} else {
$environment = APPLICATION_ENV;
}
return getConfig($key, $environment);
} elseif (substr($func, 0, 3) == 'set') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
$key = Inflector::lower($uncamelizeMethod);
$value = Arrays::first($argv);
if (isset($argv[1])) {
$environment = $argv[1];
} else {
$environment = 'all';
}
setConfig($key, $value, $environment);
return $this;
} elseif (substr($func, 0, 3) == 'has') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
$key = Inflector::lower($uncamelizeMethod);
if (isset($argv[0])) {
$environment = $argv[0];
} else {
$environment = APPLICATION_ENV;
}
return null !== getConfig($key, $environment);
}
}
示例3: libProject
function libProject($lib, $args = null)
{
$lib = strtolower(Inflector::uncamelize($lib));
$script = str_replace('_', DS, $lib) . '.php';
if (fnmatch('*_*', $lib)) {
$class = 'Thin\\' . str_replace('_', '\\', $lib);
$tab = explode('\\', $class);
$first = $tab[1];
$class = str_replace('Thin\\' . $first, 'Thin\\' . ucfirst($first) . 'Project', $class);
if (count($tab) > 2) {
for ($i = 2; $i < count($tab); $i++) {
$seg = trim($tab[$i]);
$class = str_replace('\\' . $seg, '\\' . ucfirst($seg), $class);
}
}
} else {
$class = 'Thin\\' . ucfirst($lib) . 'Project';
}
$file = path('module') . DS . 'classes' . DS . $script;
if (file_exists($file)) {
require_once $file;
if (empty($args)) {
return new $class();
} else {
if (!is_array($args)) {
if (is_string($args)) {
if (fnmatch('*,*', $args)) {
$args = explode(',', str_replace(', ', ',', $args));
} else {
$args = [$args];
}
} else {
$args = [$args];
}
}
$methods = get_class_methods($class);
if (in_array('instance', $methods)) {
$check = new \ReflectionMethod($class, 'instance');
if ($check->isStatic()) {
return call_user_func_array([$class, 'instance'], $args);
}
} else {
return construct($class, $args);
}
}
}
if (class_exists('Thin\\' . $lib)) {
$c = 'Thin\\' . $lib;
return new $c();
}
if (class_exists($lib)) {
return new $lib();
}
throw new Exception("The Project {$class} does not exist.");
}
示例4: initialize_association_options
static function initialize_association_options($class_name, $plural_name, &$options)
{
parent::initialize_association_options($class_name, $plural_name, $options);
if (!isset($options['join_table'])) {
$tableized_class = Inflector::tableize($class_name);
$tableized_foreign_class = Inflector::tableize($options['class_name']);
$options['join_table'] = $tableized_class < $tableized_foreign_class ? $tableized_class . '_' . $tableized_foreign_class : $tableized_foreign_class . '_' . $tableized_class;
}
if (!isset($options['association_foreign_key'])) {
$options['association_foreign_key'] = Inflector::uncamelize($options['class_name']) . '_id';
}
}
示例5: initialize_association_options
static function initialize_association_options($class_name, $plural_name, &$options)
{
if (!isset($options['class_name'])) {
$options['class_name'] = Inflector::classify($plural_name);
}
if (!isset($options['foreign_key'])) {
$options['foreign_key'] = Inflector::uncamelize($class_name) . '_id';
}
if (!isset($options['validate'])) {
$options['validate'] = true;
}
}
示例6: __call
public function __call($method, $args)
{
$db = Inflector::uncamelize($method);
if (fnmatch('*_*', $db)) {
list($database, $table) = explode('_', $db, 2);
} else {
$database = SITE_NAME;
$table = $db;
}
$connection = $this->start();
$odm = $connection->database(SITE_NAME);
return $odm->collection("{$database}.{$table}");
}
示例7: __callStatic
public static function __callStatic($method, $args)
{
$table = Inflector::uncamelize($method);
$database = 'system';
if (empty($args)) {
return core('fast')->instanciate($database, $table);
} elseif (count($args) == 1) {
$id = current($args);
if (is_numeric($id)) {
return core('fast')->instanciate($database, $table)->find((int) $id);
}
}
}
示例8: __callStatic
public static function __callStatic($method, $args)
{
$db = Inflector::uncamelize($method);
if (fnmatch('*_*', $db)) {
list($database, $table) = explode('_', $db, 2);
} else {
$database = SITE_NAME;
$table = $db;
}
if (empty($args)) {
return lib('mysql')->table($table, $database);
}
}
示例9: __callstatic
public static function __callstatic($method, $args)
{
if (substr($method, 0, 3) == 'get') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 3)));
$var = Inflector::lower($uncamelizeMethod);
$return = static::get($var);
return $return;
} elseif (substr($method, 0, 3) == 'set') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 3)));
$var = Inflector::lower($uncamelizeMethod);
$value = current($args);
return static::set($var, $value);
}
}
示例10: __call
public function __call($m, $a)
{
$action = array_shift($a);
if (!empty($a)) {
$success = array_shift($a);
} else {
$success = null;
}
if (!empty($a)) {
$error = array_shift($a);
} else {
$error = null;
}
return $this->step(Inflector::uncamelize($m), $action, $success, $error, $a);
}
示例11: initialize_association_options
static function initialize_association_options($class_name, $singular_name, &$options)
{
if (!isset($options['class_name'])) {
$options['class_name'] = Inflector::camelize($singular_name);
}
if (!isset($options['foreign_key'])) {
$options['foreign_key'] = Inflector::uncamelize($options['class_name']) . '_id';
}
if (isset($options['polymorphic']) && $options['polymorphic']) {
if (!isset($options['foreign_type'])) {
$options['foreign_type'] = Inflector::uncamelize($options['class_name']) . '_type';
}
}
if (!isset($options['validate'])) {
$options['validate'] = true;
}
}
示例12: __construct
public function __construct($db = null, $table = null)
{
$this->db = is_null($db) ? SITE_NAME : $db;
$this->table = is_null($table) ? 'core' : $table;
$dir = Config::get('dir.flat.store', session_save_path());
if (!is_dir($dir)) {
File::mkdir($dir);
}
$dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
if (!is_dir($dir)) {
File::mkdir($dir);
}
$this->file = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table)) . '.flat';
if (!file_exists($this->file)) {
File::put($this->file, serialize([]));
}
Now::set('flat.collection.' . $this->db . '.' . $this->table, lib('sessy', [$this->db, $this->table, unserialize(File::read($this->file))]));
}
示例13: __callStatic
public static function __callStatic($method, $args)
{
$db = Inflector::uncamelize($method);
if (fnmatch('*_*', $db)) {
list($database, $table) = explode('_', $db, 2);
} else {
$database = SITE_NAME;
$table = $db;
}
if (empty($args)) {
return core('fast')->instanciate($database, $table);
} elseif (count($args) == 1) {
$id = current($args);
if (is_numeric($id)) {
return core('fast')->instanciate($database, $table)->find((int) $id);
}
}
}
示例14: __call
public function __call($func, $argv)
{
if (substr($func, 0, 3) == 'get') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
$key = Inflector::lower($uncamelizeMethod);
return getMeta($key);
} elseif (substr($func, 0, 3) == 'set') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
$key = Inflector::lower($uncamelizeMethod);
$value = Arrays::first($argv);
setMeta($key, $value);
return $this;
} elseif (substr($func, 0, 3) == 'has') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
$key = Inflector::lower($uncamelizeMethod);
return null !== getMeta($key);
}
}
示例15: __callStatic
public static function __callStatic($method, $args)
{
$db = Inflector::uncamelize($method);
if (fnmatch('*_*', $db)) {
list($database, $table) = explode('_', $db, 2);
} else {
$database = SITE_NAME;
$table = $db;
}
if (!count($args)) {
return Moo\Db::instance($database, $table);
} elseif (count($args) == 1) {
$id = Arrays::first($args);
if (is_numeric($id)) {
return Moo\Db::instance($database, $table)->find($id);
}
}
}