当前位置: 首页>>代码示例>>PHP>>正文


PHP CrowdfundingHelperRoute::getReportRoute方法代码示例

本文整理汇总了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);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:48,代码来源:report.php


注:本文中的CrowdfundingHelperRoute::getReportRoute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。