When I have if statements for views I make a helper to simplify the code rather than if this if that all over the places, simply pass the variables to the helper and get the values I need returned.
But what about for the controller? I have a rather ugly block of code used in a few places and it sure would streamline changes. Where should code like this go? Its used in about 7 places and its rather horrible
Example :
if ( !empty( $auth_id ) ) {
$rank = $this->Auth->user( 'rank' );
$display = $this->Session->read( 'Settings.display' );
$tests = $this->Session->read( 'Tests.sent' );
if ( empty ( $tests ) ) {
$tests = $this->Test->Application->getAllApplications($this->Auth->user('id'), $this->Auth->user('rank'));
$this->Session->write( 'Tests.sent' , $tests);
}
$tests = $this->Session->read('Tests.sent');
} else {
$rank = '0';
$display = '0';
}
Thanks
Dave
No comments:
Post a Comment