|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-14 12:48 UTC] sylvain dot lecoy at gmail dot com
Description:
------------
In order to extends the OAuth object, make the constructor
non final so we can
redefine __constrcut().
This is useful for framework like drupal, and you can then
create an OAuthAdapter
(which extends OAuth pecl) and instantiate it by giving a
module name.
e.g. new OAuthAdapter("facebook"); consumer_key and secret
are stored by drupal
convention so we can skip this step for d?veloppment and
make the lib very dev-
friendly. (the pattern adapter allows redefinition in case
the user don't have
control on his webserver - shared environment for instance).
Here is some code to illustrate a work around, but using
__construct will be a
lot better.
I am using 0.99.9 (on windows machine dev) maybe it has been
changed on 1.0.0 ?
Sylvain Lecoy
Reproduce code:
---------------
class OAuthAdapter extends OAuth implements DrupalOAuthClient {
private $mModule;
static function construct($module, $signature_method = NULL, $auth_type =
NULL) {
$consumer_key = variable_get($module . '_consumer_key', '');
$consumer_secret = variable_get($module . '_consumer_secret', '');
$oauth = new OAuthAdapter($consumer_key, $consumer_secret,
$signature_method, $auth_type);
$oauth->mModule = $module;
// If the user is not anonymous (can happen with cron auto-sync tasks).
if ($GLOBALS['user']->uid != 0) {
$oauth->setCaller($GLOBALS['user']->uid);
}
return $oauth;
}
}
Expected result:
----------------
class OAuthAdapter extends OAuth implements
DrupalOAuthClient {
private $mModule;
function __construct($module, $signature_method = NULL,
$auth_type =
NULL) {
$this->mModule = $module;
$consumer_key = variable_get($module . '_consumer_key',
'');
$consumer_secret = variable_get($module .
'_consumer_secret', '');
parent::__construct($consumer_key, $consumer_secret,
$signature_method, $auth_type);
// If the user is not anonymous (can happen with cron
auto-sync tasks).
if ($GLOBALS['user']->uid != 0) {
$this->setCaller($GLOBALS['user']->uid);
}
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 11:00:01 2025 UTC |
Also, why the stable release as tagged with -dev suffix when checking with the phpversion() function. For instance on the live server I fetched last stable extension but the output of phpversion('oauth') still displays 1.0-dev. It should be 1.1.0 shouldn't it ?