I'm propably too tired but I've been wrestling with this one for a while. A container can either have a layout on its own, or it can have a parent somewhere up the hierarchy that has a layout. I need to find that layout no matter how far up the line it is.
The object $container has a property $parent which, if not null, references another $container object (same type).
I think this code has a problem in the while condition?
private function findInheritedLayout($container) {
do {
if ( $container->getLayoutTemplate() ) {
return $container->getLayoutTemplate();
}
else {
if ( $container->getParent() ) {
$container = $container->getParent();
}
else {
return null;
}
}
} while ( $container->getParent() ); //flawed? looks for a parent one step too far?
}