mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-26 03:30:32 +08:00
...
This commit is contained in:
@@ -179,7 +179,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
* @param mixed $data the data to be copied from, must be an array or an object implementing `Traversable`
|
||||
* @throws Exception if data is neither an array nor an iterator.
|
||||
*/
|
||||
public function fromArray($data)
|
||||
public function copyFrom($data)
|
||||
{
|
||||
if (is_array($data) || $data instanceof \Traversable) {
|
||||
if ($this->_d !== array()) {
|
||||
|
||||
@@ -342,27 +342,4 @@ class Object
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the object properties with the specified array.
|
||||
* @param array $array name-value pairs to be used to initialize the properties of this object.
|
||||
* @return Object the object itself
|
||||
*/
|
||||
public function fromArray($array)
|
||||
{
|
||||
foreach ($array as $name => $value) {
|
||||
$this->$name = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object in terms of an array.
|
||||
* The default implementation will return the result of PHP function `get_object_vars()`.
|
||||
* @return array the array representation of this object.
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
|
||||
* @param mixed $data the data to be copied from, must be an array or an object implementing `Traversable`
|
||||
* @throws Exception if data is neither an array nor an object implementing `Traversable`.
|
||||
*/
|
||||
public function fromArray($data)
|
||||
public function copyFrom($data)
|
||||
{
|
||||
if (is_array($data) || $data instanceof \Traversable) {
|
||||
if ($this->_c > 0) {
|
||||
|
||||
21
framework/db/ar/ActiveQueryBuilder.php
Normal file
21
framework/db/ar/ActiveQueryBuilder.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* ActiveQueryBuilder class file.
|
||||
*
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright © 2008-2012 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\db\ar;
|
||||
|
||||
/**
|
||||
* ActiveQueryBuilder is ...
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class ActiveQueryBuilder extends \yii\base\Object
|
||||
{
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace yii\db\dao;
|
||||
|
||||
use yii\db\Exception;
|
||||
|
||||
/**
|
||||
* TableSchema represents the metadata of a database table.
|
||||
*
|
||||
@@ -82,4 +84,18 @@ class TableSchema extends \yii\base\Object
|
||||
{
|
||||
return array_keys($this->columns);
|
||||
}
|
||||
|
||||
public function fixPrimaryKey($keys)
|
||||
{
|
||||
if (!is_array($keys)) {
|
||||
$keys = array($keys);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
if (isset($this->columns[$key])) {
|
||||
$this->columns[$key]->isPrimaryKey = true;
|
||||
} else {
|
||||
throw new Exception("Primary key '$key' cannot be found in table '{$this->name}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace yii\util;
|
||||
/**
|
||||
* Text helper
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Alex Makarov <sam@rmcreative.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Text
|
||||
@@ -23,9 +25,9 @@ class Text
|
||||
* @param string $name the word to be pluralized
|
||||
* @return string the pluralized word
|
||||
*/
|
||||
public function pluralize($name)
|
||||
public static function pluralize($name)
|
||||
{
|
||||
$rules=array(
|
||||
$rules = array(
|
||||
'/(x|ch|ss|sh|us|as|is|os)$/i' => '\1es',
|
||||
'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
|
||||
'/(m)an$/i' => '\1en',
|
||||
@@ -33,11 +35,17 @@ class Text
|
||||
'/(r)y$/i' => '\1ies',
|
||||
'/s$/' => 's',
|
||||
);
|
||||
foreach($rules as $rule=>$replacement)
|
||||
foreach ($rules as $rule => $replacement)
|
||||
{
|
||||
if(preg_match($rule,$name))
|
||||
return preg_replace($rule,$replacement,$name);
|
||||
if (preg_match($rule, $name)) {
|
||||
return preg_replace($rule, $replacement, $name);
|
||||
}
|
||||
}
|
||||
return $name.'s';
|
||||
return $name . 's';
|
||||
}
|
||||
|
||||
public static function dd($value)
|
||||
{
|
||||
return trim(strtolower(str_replace(array('-', '_', '.'), ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $value))));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user