Esempio n. 1
0
 public function after()
 {
     $this->prepareViewBeforeRendering();
     //var_dump($this->view->pageTitle);exit;
     $this->response->body = $this->view->render();
     parent::after();
 }
Esempio n. 2
0
 public function run($action)
 {
     try {
         parent::run($action);
     } catch (HttpException $e) {
         $e->setOrigin(HttpException::ORIGIN_ADMIN);
         throw $e;
     }
 }
Esempio n. 3
0
    public function addToCartLink($productId)
    {
        static $productsInCart;
        if (!$productsInCart) {
            $productsInCart = $this->controller->getProductsInCartIds();
        }
        if (!in_array($productId, $productsInCart)) {
            ?>
            <a href="/cart/view" class="btn btn-primary pull-left ladda-button buy-link js-add-to-cart-shortcut"
               data-product-id="<?php 
            echo $productId;
            ?>
"
               data-style="contract" title="Add to Cart"><span class="ladda-label"><span
                            class="glyphicon glyphicon-shopping-cart"></span></span></a><?php 
        } else {
            ?>
<a href="/cart/view" class="btn btn-success btn-sm pull-left ladda-button buy-link added-to-cart" data-product-id="<?php 
            echo $productId;
            ?>
"
                    data-style="contract" title="Go to Cart">Added to Cart</a> <?php 
        }
    }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 public function after()
 {
     $this->response->setHeader('Content-Type', $this->responseFormat . '; charset=utf-8');
     if ($this->request->method == 'HEAD') {
         $this->response->body = '';
         return;
     }
     if ($this->response->body instanceof Model) {
         /** @var Model $tmpData */
         $tmpData = $this->response->body;
         $tmpData = $tmpData->as_array();
         foreach ($tmpData as $key => $field) {
             if (!in_array($key, $this->exposedFields()) && $key != $this->model->id_field) {
                 unset($tmpData[$key]);
             }
         }
         $this->response->body = $tmpData;
     }
     if ($this->isCollectionRequested) {
         $this->response->body = array_merge(['data' => $this->response->body], $this->meta);
     }
     if ($this->responseFormat == self::FORMAT_XML) {
         $this->response->body = $this->asXML(is_array($this->response->body) ? $this->response->body : []);
     } else {
         $this->response->body = $this->response->body || is_array($this->response->body) ? json_encode($this->response->body) : '';
     }
     if (!is_string($this->response->body)) {
         $this->response->body = (string) $this->response->body;
     }
     //file_put_contents(__DIR__.'/../../../rest.log', date('Y-m-d H:i:s') . "\n" . $this->response->body . "\n\n\n", FILE_APPEND);
     if (!$this instanceof ErrorController) {
         parent::after();
     }
 }
Esempio n. 5
0
 public function after()
 {
     $this->response->body = $this->view->render();
     parent::after();
 }
Esempio n. 6
0
 /**
  * @inheritdoc
  */
 public function after()
 {
     $this->response->setHeader('Content-Type', $this->responseFormat . '; charset=utf-8');
     if ($this->request->method == 'HEAD') {
         $this->response->body = '';
         return;
     }
     if ($this->response->body instanceof Model) {
         /** @var Model $tmpData */
         $tmpData = $this->response->body;
         $tmpData = $tmpData->as_array();
         foreach ($tmpData as $key => $field) {
             if (!in_array($key, $this->exposedFields()) && $key != $this->model->id_field) {
                 unset($tmpData[$key]);
             }
         }
         $this->response->body = $tmpData;
     }
     if ($this->responseFormat == self::FORMAT_XML) {
         $this->response->body = $this->asXML(is_array($this->response->body) ? $this->response->body : []);
         // echo $this->response->body;exit;
     } else {
         $this->response->body = $this->response->body || is_array($this->response->body) ? json_encode($this->response->body) : '';
     }
     if (!is_string($this->response->body)) {
         $this->response->body = (string) $this->response->body;
     }
     if (!$this instanceof ErrorController) {
         parent::after();
     }
 }