本文整理匯總了PHP中CrowdfundingHelperRoute::getReportRoute方法的典型用法代碼示例。如果您正苦於以下問題:PHP CrowdfundingHelperRoute::getReportRoute方法的具體用法?PHP CrowdfundingHelperRoute::getReportRoute怎麽用?PHP CrowdfundingHelperRoute::getReportRoute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CrowdfundingHelperRoute
的用法示例。
在下文中一共展示了CrowdfundingHelperRoute::getReportRoute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send
public function send()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the data from the form POST
$data = $this->input->post->get('cfreport', array(), 'array');
$itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'id');
if (!$itemId) {
$redirectOptions = array('force_direction' => CrowdfundingHelperRoute::getReportRoute());
$this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
return;
}
// Get project
$item = Crowdfunding\Project::getInstance(JFactory::getDbo(), $itemId);
$redirectOptions = array('force_direction' => CrowdfundingHelperRoute::getReportRoute($item->getId()));
$model = $this->getModel();
/** @var $model CrowdfundingModelReport */
$form = $model->getForm($data, false);
/** @var $form JForm */
if (!$form) {
throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED'));
}
// Test if the data is valid.
$validData = $model->validate($form, $data);
// Check for validation errors.
if ($validData === false) {
$errors = $form->getErrors();
$error = array_shift($errors);
$msg = $error->getMessage();
$this->displayNotice($msg, $redirectOptions);
return;
}
try {
$userId = (int) JFactory::getUser()->get('id');
if ($userId > 0) {
$validData['user_id'] = $userId;
}
$model->save($validData);
} catch (RuntimeException $e) {
$this->displayNotice($e->getMessage(), $redirectOptions);
return;
} catch (Exception $e) {
JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
}
// Redirect to next page
$this->displayMessage(JText::_('COM_CROWDFUNDING_REPORT_SENT_SUCCESSFULLY'), $redirectOptions);
}