redirectUnless code in 'Writing slimmer Controllers' is incorrect
Closed this issue · 1 comments
Deleted user commented
function redirectUnless code has a little bug in it on page
http://josediazgonzalez.com/2013/12/24/writing-slimmer-controllers/
Here is the function as documented
<?php
public function redirectUnless($variable, $redirectTo = null) {
if (empty($variable)) { # <--- wrong
return;
}
if (empty($redirectTo)) {
$redirectTo = array('action' => 'index');
}
return $this->redirect($redirectTo);
}
?>
Line 2 should be
<?php
public function redirectUnless($variable, $redirectTo = null) {
if (!empty($variable)) { # if NOT empty
return;
}
// ...
}
?>
josegonzalez commented
Fixed!