This commit is contained in:
Qiang Xue
2011-12-31 21:08:37 -05:00
parent 95135f11ef
commit 2f37d09367
12 changed files with 732 additions and 1429 deletions

View File

@@ -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()) {

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -0,0 +1,21 @@
<?php
/**
* ActiveQueryBuilder class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 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
{
}

View File

File diff suppressed because it is too large Load Diff

View File

@@ -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}'.");
}
}
}
}

View File

@@ -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))));
}
}