Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding base model interface

  • Loading branch information...
commit b6e4b823f0dbf5370b343200786d04bce1b61d8a 1 parent 424ebee
@zombor zombor authored
View
3  classes/kohana/model/oauth2/access/token.php
@@ -11,7 +11,8 @@
*/
class Kohana_Model_OAuth2_Access_Token
extends Model_Database
- implements Model_OAuth2_Interface_Access_Token
+ implements Model_OAuth2_Interface_Access_Token,
+ Kohana_Model_OAuth2_Interface_Oauth
{
$this->_table = 'oauth2_access_tokens';
View
3  classes/kohana/model/oauth2/auth/code.php
@@ -11,7 +11,8 @@
*/
class Kohana_Model_OAuth2_Auth_Code
extends Model_Database
- implements Model_OAuth2_Interface_Auth_Code
+ implements Model_OAuth2_Interface_Auth_Code,
+ Kohana_Model_OAuth2_Interface_Oauth
{
protected $_table = 'oauth2_auth_codes';
View
22 classes/kohana/model/oauth2/client.php
@@ -11,11 +11,22 @@
*/
class Kohana_Model_OAuth2_Client
extends Model_Database
- implements Kohana_Model_OAuth2_Interface_Client
+ implements Kohana_Model_OAuth2_Interface_Client,
+ Kohana_Model_OAuth2_Interface_Oauth
{
protected $_table = 'oauth2_clients';
/**
+ * Determine if this model is loaded
+ *
+ * @return bool
+ */
+ public function loaded()
+ {
+ return isset($this->client_id);
+ }
+
+ /**
* Find a client
*
* @param string $client_id
@@ -33,7 +44,7 @@ public static function find_client($client_id, $client_secret = NULL)
$query->where('client_id', '=', $client_secret);
}
- $result = $query->as_object()->execute();
+ $result = $query->as_object('Model_OAuth2_Client')->execute();
if (count($result))
{
@@ -64,7 +75,12 @@ public static function create_client(
->values($vals)
->execute();
- return (object) array_combine($keys, $vals);
+ $client = new Model_Oauth2_Client;
+ $client->client_id = $client_id;
+ $client->client_secret = $client_secret;
+ $client->redirect_uri = $redirect_uri;
+
+ return $client;
}
/**
View
20 classes/kohana/model/oauth2/interface/oauth.php
@@ -0,0 +1,20 @@
+<?php defined('SYSPATH') or die('No direct script access.');
+
+/**
+ * Base model for oauth2 models
+ *
+ * @package OAuth2
+ * @category Model
+ * @author Managed I.T.
+ * @copyright (c) 2011 Managed I.T.
+ * @license https://github.com/managedit/kohana-oauth2/blob/master/LICENSE.md
+ */
+interface Kohana_Model_OAuth2_Interface_Oauth
+{
+ /**
+ * Determines if this model is loaded
+ *
+ * @return bool
+ */
+ public function loaded();
+}
View
3  classes/kohana/model/oauth2/refresh/token.php
@@ -11,7 +11,8 @@
*/
class Kohana_Model_OAuth2_Refresh_Token
extends Model_Database
- implements Model_OAuth2_Interface_Refresh_Token
+ implements Model_OAuth2_Interface_Refresh_Token,
+ Kohana_Model_OAuth2_Interface_Oauth
{
protected $_table = 'oauth2_refresh_tokens';
Please sign in to comment.
Something went wrong with that request. Please try again.