Re: extending Auth DB container
| From: | Martin Jansen | Date: | Wed, 20 Mar 2002 18:10:38 +0000 |
| Subject: | Re: extending Auth DB container | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-1002@lists.php.net to get a copy of this message | ||
On Thu, 21 Mar 2002 01:50:45 +0800, Ken Chew wrote:
>I am a new user of pear and wanted to extend the DB container
>class for Auth to add some of my own function for the user auth.
>
>But I note that this part
> 269 function _factory($driver, $options = "")
> 270 {
> 271 $storage_path = "Auth/Container/" . $driver . ".php";
> 272 $storage_class = "Auth_Container_" . $driver;
> 273
> 274 require_once $storage_path;
> 275
> 276 return new $storage_class($options);
> 277 }
>
>default to looking for the driver in the pear directory.
>
>Now, I do not have write access to this directory (actually do not
>want to write to there). If I want to put my own driver file
>somewhere, what should?
For now you can do:
class MyAuth extends Auth {
function MyAuth($filename, $name, $options = "")
{
/* .... */
$this->storage = $this->_factory($filename, $name, $options);
}
function _factory($filename, $name, $options)
{
require_once $filename;
$storage_class = "Auth_Container_" . $name;
return new $storage_class($options);
}
}
and then call it via
$foo = new MyAuth("/foo/bar/file.php", "myContainer");
Perhaps such a feature will be natively supported by Auth
one fine day, but not today and not tomorrow :-).
- Martin
--
Martin Jansen, <mail@martin-jansen.de>
http://www.martin-jansen.de/