Ejemplo n.º 1
0
 /**
  * @param int $projectId
  * @param Joomla\Registry\Registry $params
  *
  * @return stdClass
  * @throws UnexpectedValueException
  */
 protected function prepareItem($projectId, $params)
 {
     jimport("crowdfunding.project");
     $project = new CrowdFundingProject(JFactory::getDbo());
     $project->load($projectId);
     if (!$project->getId()) {
         throw new UnexpectedValueException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"));
     }
     if ($project->isCompleted()) {
         throw new UnexpectedValueException(JText::_("COM_CROWDFUNDING_ERROR_COMPLETED_PROJECT"));
     }
     // Get currency
     jimport("crowdfunding.currency");
     $currencyId = $params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $params);
     $item = new stdClass();
     $item->id = $project->getId();
     $item->title = $project->getTitle();
     $item->slug = $project->getSlug();
     $item->catslug = $project->getCatSlug();
     $item->rewardId = $this->paymentProcess->rewardId;
     $item->amount = $this->paymentProcess->amount;
     $item->currency = $this->currency->getAbbr();
     return $item;
 }