5
我想通過控制檯shell(最終通過cron作業)從CakePHP 2.1.2發送一封電子郵件。我發送的視圖是一個帶有指向應用程序網頁鏈接的日曆。我發現的問題是,網址沒有包含正確的路徑,而且從我讀過的內容來看,這是因爲我使用控制檯時沒有請求對象。例如,如果我在瀏覽器中創建視圖我得到的鏈接是這樣的:從CakePHP創建完整的URL 2.1.2控制檯Shell
http://localhost/ReportMonitor/scheduledReports/index/show_date:2012-06-10/result:GOOD
但電子郵件中使用相同的代碼我得到這個:
http://localhost/scheduledReports/index/show_date:2012-06-10/result:GOOD
這是接近,但沒有雪茄。
我一直在努力尋找全球性的,我可以設置的地方只是硬編碼應用子目錄,但還沒有發現任何工程尚未。這些鏈接是由這樣的代碼製作:
$newUrl = array();
$newUrl['controller'] = 'scheduledReports';
$newUrl['action'] = 'index';
$newUrl['url'] = array();
foreach ($data as $key => $value) {
$newUrl['show_date'] = "$year-$month-$key";
$newUrl['result'] = 'GOOD';
$data[$key]['num_complete'] = $this->Html->link(__('Complete: ') . $value['num_complete'], Router::reverse($newUrl, true), array('class' => 'green'));
我認爲這是一種常見的功能(在生成的控制檯電子郵件發送有效網址),但我無法弄清楚。
感謝
這可能會有所幫助http://stackoverflow.com/a/13660262/1868660 –