我有一个控制器(PromoCode_Controller),它是Page_Controller的扩展。当我触发动作时,我希望页面重定向回到它来自的页面。我目前已设置$this->redirectBack()
,但它没有开始......
我在'config.yml'文件中定义了Page_Controller:
Page_Controller:
extensions:
- PromoCode_Controller
控制器看起来像这样:
<?php
class PromoCode_Controller extends Extension {
private static $allowed_actions = array(
'DisplayCodes',
'DeleteCode'
);
public function DisplayCodes() {
//Display users promo codes
$arrayList = ArrayList::create();
$codes = PromoCode::get()->filter(array(
"OwnerID" => Member::currentUserID(),
));
foreach($codes as $code) {
$arrayList->push($code);
}
return $arrayList;
}
public function DeleteCode() {
$codeID = $this->owner->request->param("ID");
//if($codeID && $code = PromoCode::get()->byID($codeID)) {
// $code->delete();
//}
echo $codeID;
$this->redirectBack();
return $this;
}
}
我的模板中有一个链接,用于删除数据库中的代码。当我单击该链接时,它会在空白页面上打印$ codeID变量,但它不会触发重定向。
有人可以帮助指出我出错的地方吗?
答案 0 :(得分:1)
所以我偶然偶然发现了这个问题。这是完整的代码:
- (NSString*)defaultRouter {
SCDynamicStoreRef ds = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("myApplication"), NULL, NULL);
CFDictionaryRef dr6 = SCDynamicStoreCopyValue(ds, CFSTR("State:/Network/Global/IPv6"));
CFDictionaryRef dr4 = SCDynamicStoreCopyValue(ds, CFSTR("State:/Network/Global/IPv4"));
if(dr6)
{
CFStringRef router = CFDictionaryGetValue(dr6, CFSTR("PrimaryInterface"));
NSString *routerString = [NSString stringWithString:(__bridge NSString *)router];
self.primaryInterface=routerString;
return self.primaryInterface;
CFRelease(dr6);
}
else if(dr4)
{
CFStringRef router = CFDictionaryGetValue(dr4, CFSTR("PrimaryInterface"));
NSString *routerString = [NSString stringWithString:(__bridge NSString *)router];
NSLog(@"%@", routerString);
self.primaryInterface=routerString;
return self.primaryInterface;
CFRelease(dr4);
}
CFRelease(ds);
return 0;
}