示例#1
0
 /**
  * GET /products[/:id]
  * @return \Nohex\Eix\Core\Responses\Http\Html
  */
 public function httpGetForHtml()
 {
     $response = new HtmlResponse($this->getRequest());
     $id = $this->getRequest()->getParameter('id');
     $groupId = $this->getRequest()->getParameter('groupId');
     switch ($id) {
         case NULL:
             if ($groupId) {
                 $group = ProductGroups::getInstance()->findEntity($groupId);
                 $response->setData('group', $group->name);
             }
             $productList = $this->getProductList($groupId);
             if (empty($productList)) {
                 $response->setTemplateId('products/empty');
             } else {
                 $response->setTemplateId('products/index');
                 $response->setData('products', $productList);
             }
             $response->appendToTitle(_('Productes'));
             break;
         default:
             $response->setTemplateId('products/view');
             $product = $this->getForDisplay($id);
             if ($product['enabled']) {
                 $response->setData('product', $product);
                 $response->appendToTitle(_($product['name']));
             } else {
                 throw new NotFoundException('Product not found');
             }
             break;
     }
     return $response;
 }
示例#2
0
文件: Product.php 项目: eix/catalog
 public function issue()
 {
     $type = $this->getRequest()->getParameter('grup');
     // Get the relevant data.
     $products = new \Nohex\Eix\Modules\Catalog\Data\Products();
     $productList = $products->get($type);
     // Set the response.
     $this->setTemplateId('products/index');
     $this->addData('product', array('type' => $productType));
     parent::issue();
 }
示例#3
0
 private function getAuthenticationResponse($orderId)
 {
     $validationErrors = array();
     $order = null;
     try {
         $order = $this->getEntity($orderId);
         $securityCode = $this->getRequest()->getParameter('security_code');
         // Check that a security code is presented.
         if (empty($securityCode)) {
             $validationErrors[] = _('The security code is missing.');
         } else {
             // Check that the security code matches the expected one.
             if ($order->securityCode != $securityCode) {
                 $validationErrors[] = _('The security code is incorrect.');
             }
         }
     } catch (NotFoundException $exception) {
         // Same error for wrong codes and non-existing orders, to avoid
         // enumeration.
         $validationErrors[] = _('The security code is incorrect.');
     }
     $response = NULL;
     // If the validation status is empty, everything looks ok.
     if (empty($validationErrors)) {
         // If the order is new, this step just validated the customer's
         // e-mail address.
         if ($order->getStatus() == Order::STATUS_NEW) {
             // Set the status and notify the vendor.
             $order->setStatus(Order::STATUS_CONFIRMED_BY_CUSTOMER, true);
             // Store the order with the new status.
             $order->store();
             // Display the order's new status.
         }
         // Redirect to the order view page with the authentication code.
         $response = new Redirection($this->getRequest());
         $response->setNextUrl(sprintf('/comandes/%s/%s', $order->getId(), $order->getAuthenticationCode()));
     } else {
         // Validation failed.
         $response = new HtmlResponse($this->getRequest());
         $response->addErrorMessage(array('validation' => array('security_code' => $validationErrors)));
         $response->setTemplateId('orders/view');
         $response->setData('order', array('id' => $orderId));
     }
     return $response;
 }
示例#4
0
文件: Order.php 项目: eix/catalog
 public function issue()
 {
     // Load the statuses map into the response.
     $this->addData('orders', array('statuses' => OrderModel::getStatusLabels()));
     parent::issue();
 }