>I can't find the original anymore.
I saw it also and I also cannot find it :)
When I'm in need for such as global configuration options, I'm using my
'Config' component, which API simply follows SessionComponent API. NOTE
FOR ALL: it is licensed under one term: If You will use it, check if
there is a page about it on cake wiki - if it doesn't exist yet and
You're able describe what is important in correct English, make page
about it on wiki and maintain it in future.
app/controllers/components/config.php:
<?php
class ConfigComponent extends Object
{
function __construct() {
parent::__construct();
$config =& Configure::getInstance();
$vars = get_object_vars($config);
if (!array_key_exists('custom', $vars) ||
!is_array($config->custom)) {
$config->custom = array();
}
}
function write($name, $value)
{
$config =& Configure::getInstance();
$config->custom[$name] = $value;
}
function read($name = null)
{
if (!is_null($name)) {
if (ConfigComponent::check($name)) {
$config =& Configure::getInstance();
return $config->custom[$name];
}
else {
return null;
}
}
else {
$config =& Configure::getInstance();
return $config->custom;
}
}
function del($name)
{
if (ConfigComponent::check($name)) {
$config =& Configure::getInstance();
$unset($config->custom[$name]);
}
}
function delete($name)
{
ConfigComponent::delete($name);
}
function check($name)
{
$config =& Configure::getInstance();
return isset($config->custom[$name]);
}
}
?>
Usage in controller:
var $uses = array('Config', ...);
and then
$this->set('menuArray', $this->Config->read('menuArray'));
OR anywhere outside of this controller (if dispatcher is processid it's
method) - in view, element, even in model:
$menu = ConfigComponent::read('menuArray');
So in this particular case I will have to put in bootstrap.php code:
$_conf =& Configure::getInstance();
$_conf->custom = array('xyz' => 123);
unset($_conf);
and then access it as is described above.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---