本文整理汇总了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);
}