Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding base model interface

  • Loading branch information...
commit b6e4b823f0dbf5370b343200786d04bce1b61d8a 1 parent 424ebee
Jeremy Bush zombor authored
3  classes/kohana/model/oauth2/access/token.php
@@ -11,7 +11,8 @@
11 11 */
12 12 class Kohana_Model_OAuth2_Access_Token
13 13 extends Model_Database
14   - implements Model_OAuth2_Interface_Access_Token
  14 + implements Model_OAuth2_Interface_Access_Token,
  15 + Kohana_Model_OAuth2_Interface_Oauth
15 16 {
16 17 $this->_table = 'oauth2_access_tokens';
17 18
3  classes/kohana/model/oauth2/auth/code.php
@@ -11,7 +11,8 @@
11 11 */
12 12 class Kohana_Model_OAuth2_Auth_Code
13 13 extends Model_Database
14   - implements Model_OAuth2_Interface_Auth_Code
  14 + implements Model_OAuth2_Interface_Auth_Code,
  15 + Kohana_Model_OAuth2_Interface_Oauth
15 16 {
16 17 protected $_table = 'oauth2_auth_codes';
17 18
22 classes/kohana/model/oauth2/client.php
@@ -11,11 +11,22 @@
11 11 */
12 12 class Kohana_Model_OAuth2_Client
13 13 extends Model_Database
14   - implements Kohana_Model_OAuth2_Interface_Client
  14 + implements Kohana_Model_OAuth2_Interface_Client,
  15 + Kohana_Model_OAuth2_Interface_Oauth
15 16 {
16 17 protected $_table = 'oauth2_clients';
17 18
18 19 /**
  20 + * Determine if this model is loaded
  21 + *
  22 + * @return bool
  23 + */
  24 + public function loaded()
  25 + {
  26 + return isset($this->client_id);
  27 + }
  28 +
  29 + /**
19 30 * Find a client
20 31 *
21 32 * @param string $client_id
@@ -33,7 +44,7 @@ public static function find_client($client_id, $client_secret = NULL)
33 44 $query->where('client_id', '=', $client_secret);
34 45 }
35 46
36   - $result = $query->as_object()->execute();
  47 + $result = $query->as_object('Model_OAuth2_Client')->execute();
37 48
38 49 if (count($result))
39 50 {
@@ -64,7 +75,12 @@ public static function create_client(
64 75 ->values($vals)
65 76 ->execute();
66 77
67   - return (object) array_combine($keys, $vals);
  78 + $client = new Model_Oauth2_Client;
  79 + $client->client_id = $client_id;
  80 + $client->client_secret = $client_secret;
  81 + $client->redirect_uri = $redirect_uri;
  82 +
  83 + return $client;
68 84 }
69 85
70 86 /**
20 classes/kohana/model/oauth2/interface/oauth.php
... ... @@ -0,0 +1,20 @@
  1 +<?php defined('SYSPATH') or die('No direct script access.');
  2 +
  3 +/**
  4 + * Base model for oauth2 models
  5 + *
  6 + * @package OAuth2
  7 + * @category Model
  8 + * @author Managed I.T.
  9 + * @copyright (c) 2011 Managed I.T.
  10 + * @license https://github.com/managedit/kohana-oauth2/blob/master/LICENSE.md
  11 + */
  12 +interface Kohana_Model_OAuth2_Interface_Oauth
  13 +{
  14 + /**
  15 + * Determines if this model is loaded
  16 + *
  17 + * @return bool
  18 + */
  19 + public function loaded();
  20 +}
3  classes/kohana/model/oauth2/refresh/token.php
@@ -11,7 +11,8 @@
11 11 */
12 12 class Kohana_Model_OAuth2_Refresh_Token
13 13 extends Model_Database
14   - implements Model_OAuth2_Interface_Refresh_Token
  14 + implements Model_OAuth2_Interface_Refresh_Token,
  15 + Kohana_Model_OAuth2_Interface_Oauth
15 16 {
16 17 protected $_table = 'oauth2_refresh_tokens';
17 18

0 comments on commit b6e4b82

Please sign in to comment.
Something went wrong with that request. Please try again.