Created
July 26, 2012 13:37
-
-
Save zombor/3182065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/application/bootstrap.php b/application/bootstrap.php | |
index 7f571c9..216f92a 100644 | |
--- a/application/bootstrap.php | |
+++ b/application/bootstrap.php | |
@@ -100,6 +100,7 @@ Kohana::$config->attach(new Config_File); | |
Kohana::modules(array( | |
'database' => MODPATH.'database', // Database access | |
'auto-modeler' => MODPATH.'auto-modeler', | |
+ 'arden' => MODPATH.'arden', | |
'kostache' => MODPATH.'kostache', | |
'minion-core' => MODPATH.'minion-core', | |
)); | |
diff --git a/application/classes/automodeler/gateway/users.php b/application/classes/automodeler/gateway/users.php | |
index 90b94b1..d09eb50 100644 | |
--- a/application/classes/automodeler/gateway/users.php | |
+++ b/application/classes/automodeler/gateway/users.php | |
@@ -1,24 +1,17 @@ | |
<?php | |
-class AutoModeler_Gateway_Users extends AutoModeler_Repository_Database | |
+class AutoModeler_Gateway_Users extends Arden_Repository_KohanaDatabase | |
{ | |
- protected $_model_name = 'Model_User'; | |
+ protected $_model_class = 'Model_User'; | |
protected $_table_name = 'users'; | |
- public function find_users(Database_Query_Builder_Select $select = NULL) | |
+ public function find_users() | |
{ | |
- $select->where('active', '=', TRUE); | |
- return $this->_load_set($select); | |
+ return $this->load_set([]); | |
} | |
- public function find_user($id, Database_Query_Builder_Select $select = NULL) | |
+ public function find_user($id) | |
{ | |
- if ($select === NULL) | |
- { | |
- $select = db::select(); | |
- } | |
- | |
- $select->where('id', '=', $id); | |
- return $this->_load_object($select); | |
+ return $this->load_object(['id' => $id]); | |
} | |
} | |
diff --git a/application/classes/context/user/add.php b/application/classes/context/user/add.php | |
index 7813749..084796d 100644 | |
--- a/application/classes/context/user/add.php | |
+++ b/application/classes/context/user/add.php | |
@@ -24,15 +24,11 @@ class Context_User_Add | |
$user->assign_data = function(array $data) use($user) | |
{ | |
- $user->data( | |
- [ | |
- 'email' => arr::get($data, 'email'), | |
- 'password' => arr::get($data, 'password'), | |
- 'first_name' => arr::get($data, 'first_name'), | |
- 'last_name' => arr::get($data, 'last_name'), | |
- 'middle_name' => arr::get($data, 'middle_name'), | |
- ] | |
- ); | |
+ $user->email = arr::get($data, 'email'); | |
+ $user->password = arr::get($data, 'password'); | |
+ $user->first_name = arr::get($data, 'first_name'); | |
+ $user->last_name = arr::get($data, 'last_name'); | |
+ $user->middle_name = arr::get($data, 'middle_name'); | |
}; | |
$this->_data = $data; | |
@@ -50,7 +46,8 @@ class Context_User_Add | |
try | |
{ | |
$user = call_user_func($this->_user->create, $this->_data, $this->_groups, $this->_user_gateway, $this->_group_gateway); | |
- $status = ['status' => self::SUCCESS, 'data_array' => $user->as_array()]; | |
+ die(var_dump($user)); | |
+ $status = ['status' => self::SUCCESS, 'data_array' => $this->_data]; | |
} | |
catch (AutoModeler_Exception_Validation $e) | |
{ | |
diff --git a/application/classes/context/user/add/factory.php b/application/classes/context/user/add/factory.php | |
index 6a39f83..8a937f6 100644 | |
--- a/application/classes/context/user/add/factory.php | |
+++ b/application/classes/context/user/add/factory.php | |
@@ -21,7 +21,13 @@ class Context_User_Add_Factory | |
public function gateway() | |
{ | |
- return new AutoModeler_Gateway_Users(Database::instance()); | |
+ return new AutoModeler_Gateway_Users( | |
+ Database::instance(), | |
+ new Database_Query_Builder_Select, | |
+ new Database_Query_Builder_Insert, | |
+ new Database_Query_Builder_Update, | |
+ new Database_Query_Builder_Delete | |
+ ); | |
} | |
public function group_gateway() | |
diff --git a/application/classes/context/user/list/factory.php b/application/classes/context/user/list/factory.php | |
index 7f0bd1c..9bb1365 100644 | |
--- a/application/classes/context/user/list/factory.php | |
+++ b/application/classes/context/user/list/factory.php | |
@@ -9,6 +9,12 @@ class Context_User_List_Factory | |
public function gateway() | |
{ | |
- return new AutoModeler_Gateway_Users(Database::instance()); | |
+ return new AutoModeler_Gateway_Users( | |
+ Database::instance(), | |
+ new Database_Query_Builder_Select, | |
+ new Database_Query_Builder_Insert, | |
+ new Database_Query_Builder_Update, | |
+ new Database_Query_Builder_Delete | |
+ ); | |
} | |
} | |
diff --git a/application/classes/model/user.php b/application/classes/model/user.php | |
index bd54074..ea212d2 100644 | |
--- a/application/classes/model/user.php | |
+++ b/application/classes/model/user.php | |
@@ -1,31 +1,13 @@ | |
<?php | |
-class Model_User extends AutoModeler_Model | |
+class Model_User | |
{ | |
- protected $_data = array( | |
- 'id' => NULL, | |
- 'email' => NULL, | |
- 'password' => NULL, | |
- 'first_name' => NULL, | |
- 'last_name' => NULL, | |
- 'middle_name' => NULL, | |
- ); | |
- | |
- protected $_rules = array( | |
- 'email' => array( | |
- array('not_empty'), | |
- array('email'), | |
- ), | |
- 'first_name' => array( | |
- array('not_empty'), | |
- ), | |
- 'last_name' => array( | |
- array('not_empty'), | |
- ), | |
- 'password' => array( | |
- array('not_empty'), | |
- ), | |
- ); | |
+ public $id; | |
+ public $email; | |
+ public $password; | |
+ public $first_name; | |
+ public $last_name; | |
+ public $middle_name; | |
public function name() | |
{ | |
diff --git a/automodeler.sq3 b/automodeler.sq3 | |
index ffcbb33..352d548 100644 | |
Binary files a/automodeler.sq3 and b/automodeler.sq3 differ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment