P. 1
Super Awesome Advanced CakePHP Tips

Super Awesome Advanced CakePHP Tips

|Views: 79|Likes:
Published by Remo Harsono

More info:

Published by: Remo Harsono on Dec 29, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/22/2011

pdf

text

original

Here is the full source, which is also available on GitHub.

function &getInstance($user=null) {
static $instance = array();

if ($user) {
$instance[0] =& $user;

}

if (!$instance) {
trigger_error(__("User not set.", true), E_USER_WARNING);
return false;

}

return $instance[0];

}

function store($user) {
if (empty($user)) {
return false;

}

User::getInstance($user);

}

function get($path) {
$_user =& User::getInstance();
if (strpos($path, 'User') !== 0) {
$path = sprintf('User/%s', $path);

}

if (strpos($path, '/') !== 0) {
$path = sprintf('/%s', $path);

}

$value = Set::extract($path, $_user);
if (!$value) {
return false;

}

return $value[0];

}

19

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->