%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/old2/_music/diplomka/diplomka/src/API/app/presenters/
Upload File :
Create Path :
Current File : /www/old2/_music/diplomka/diplomka/src/API/app/presenters/InventoryPresenter.php

<?php
use Nette\Application\UI\Presenter;
use Nette\Application\Responses;

/**
 * Created by JetBrains PhpStorm.
 * User: E581905
 * Date: 9/18/13
 * Time: 6:14 PM
 * To change this template use File | Settings | File Templates.
 */

class InventoryPresenter extends Presenter
{
    private $model;
    private $response;

    /** Injects Stats model into presenter
     * @param Inventory $model Model to be injected
     */
    public function injectModels(Inventory $model)
    {
        $this->model = $model;
    }

    /**
     * Sets necessary things after response startup
     */
    public function startup()
    {
        parent::startup();
        $this->response = $this->getService('httpResponse');
    }

    public function renderDefault()
    {
    }

    public function renderInventoryIds($id)
    {
        $ids = $this->model->getInventoryIds($id);
        $this->sendJSONData($ids);
    }

    public function renderInventorySnapshot($id)
    {
        $data = $this->model->getInventoryShapshot($id);
        $this->sendJSONData($data);
    }

    public function renderKeys($id)
    {
        $data = $this->model->getKeys($id);
        $this->sendJSONData($data);
    }


    /** Sends an JSON response to client containing given data object or array
     * @param Object $data Data object or array to be serialized to JSON and sent out
     */
    protected function sendJSONData($data)
    {
        $txt = json_encode($data, JSON_PRETTY_PRINT);
        $resp = new Responses\TextResponse($txt);
        $this->sendResponse($resp);
    }
}

Zerion Mini Shell 1.0