<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Basis\Kursdetails\DetailsReiter\Material;

class MaterialPresenter extends \Kufer\KuferTools\Basis\Presenter\Presenter
{
  public function present()
  {
    
    $dbwMaterial = new \DBWorkMaterial();
    $leereMaterial = $dbwMaterial->getNewObject();
    $material = \array_merge(array($leereMaterial), $this->useCaseResponse->materialien);

    return $this->getAnderenContentAlsBody($material);
  }

  protected function isDatamodulAryEmpty($datamodulArray)
  {
    return count($datamodulArray) == 1;
  }

  protected function getAnderenContent($datamodul, $key)
  {
    $viewModel = new MaterialViewModel();
    $viewModel->columns = $this->useCaseResponse->columns;
    $viewModel->material = $datamodul;
    $viewModel->index = $key;
    $tnView = new MaterialView($viewModel);

    return $tnView->show();
  }

  protected function getView()
  {
    return new MaterialReiterView($this->getViewModel());
  }

  protected function getViewModel()
  {
    $viewModel = new MaterialReiterViewModel();
    $viewModel->kurs = $this->useCaseResponse->kurs;
    $viewModel->materialien = $this->useCaseResponse->materialien;

    return $viewModel;
  }
}