====== 'Solarified' Classes ====== Some tips to create 'Solarified' classes - classes that adhere to the Solar standards and guidelines. * Always extend Solar_Base (never extend Solar). * The constructor should only receive as parameter a config array, like all other Solar constructors. * The constructor also should call %%parent::__construct($config);%% * Set a protected class property named %%$_Class_Full_Name%% to store the class configuration array. Their default values can be overridden on construction, and the precedence order is: - the config array passed to the constructor; - the values set in config file; - the default values set in the class. * Config values are accessible through the %%$this->_config['key']%% property. In your config file, you can configure the class and those values will be used when you instantiate the class using Solar::factory(): $config['Class_Full_Name'] = array( 'key' => 'value', ); * The config array is available trough $this->_config, so, inside the class: * get config value: %%$value = $this->_config['key'];%% * set config value: %%$this->_config['key'] = $value;%% * For exceptions you can use: throw $this->_exception('ERR_CODE'); * If you define ERR_CODE in the Locale file for the class (/[Class]/Locale/en_US.php) you will get a translated message string. * Also, %%$this->_exception('ERR_SOME_CODE')%% will look for /[Class]/Exception/SomeCode.php and throw it instead of a generic exception. ===== Class skeleton ===== class Vendor_Controller_Front extends Solar_Base { /** * * User-defined configuration array. * * @var array * */ protected $_Vendor_Controller_Front = array( ); /** * * Constructor. * * @param array $config User-provided configuration values. * */ public function __construct($config) { // do the "real" construction parent::__construct($config); // continue with your constructor code [...] } }