symfony sfguarduser profile methods
Wednesday, 11. November 2009, 09:16:30
http://devfactor.blogspot.com/2009/11/law-of-demeter.html
Most of the Symfony projects I’ve worked on are rife with lines of code like this (in the actions):
$this->getUser()->getGuardUser()->getProfile()->getEmail()
To conform to the above ideals (The Law Of Demeter) the code should be re-written as:
$this->getUser()->getEmail()
public function __call($method, $arguments)
{
if(is_array($arguments))
{
return call_user_func_array(array($this->getGuardUser()->getProfile(), $method), $arguments);
}
else
{
return $this->getGuardUser()->getProfile()->$method();
}
}

