The Solar_Base class is a lightweight base class from which all other Solar classes descend (not including exceptions, which descend from the Solar_Exception class). This base class provides ...
-
A standard __construct() method that reads from the config file, then combines the instantiation-time constructor parameters with the default config values for the class.
-
A $_config property to collect configuration values for the class and its parents.
-
An _exception() method for finding and returning exceptions with localized message text.
-
A locale() method for finding and returning localized text strings.
When you extend from the Solar_Base class, make sure the only
constructor parameter is $config = null
(this
is how it receives instantiation-time configuration values) and
that it calls the parent constructor at some point (with the
$config parameter passed up the chain).
For example:
<?php
class Solar_Example extends Solar_Base {
// default config values
protected $_Solar_Example = array(
'opt_1' => 'foo',
'opt_2' => 'bar',
'opt_3' => 'baz'
);
// constructor
public function __construct($config = null)
{
// pre-parent setup code
// ...
// parent construction
parent::__construct($config);
// post-parent setup
// ...
}
}