Skip to content

Commit

Permalink
Support for mutiple export (Closes o5#262)
Browse files Browse the repository at this point in the history
Fixed code style

Fixed code style
  • Loading branch information
AntikCz committed Feb 24, 2016
1 parent cec1976 commit cc2560e
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 199 deletions.
47 changes: 43 additions & 4 deletions src/Components/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Grido\Components;

use Grido\Components\Exports\BaseExport;
use Grido\Components\Exports\CsvExport;
use Grido\Grid;
use Grido\Helpers;
use Grido\Components\Actions\Action;
Expand Down Expand Up @@ -95,11 +97,30 @@ public function getOperation($need = TRUE)
/**
* Returns export component.
* @param bool $need
* @return Export
* @return CsvExport
*
* @deprecated
*/
public function getExport($need = TRUE)
{
return $this->getComponent(Export::ID, $need);
$export = $this->getComponent(BaseExport::ID, $need);
if ($export) {
$export = $export->getComponent(CsvExport::CSV_ID, $need);
}
return $export;
}

/**
* @param bool $need
* @return BaseExport[]
*/
public function getExports($need = TRUE)
{
$export = $this->getComponent(BaseExport::ID, $need);
if ($export) {
$export = $export->getComponents();
}
return $export;
}

/**********************************************************************************************/
Expand Down Expand Up @@ -185,7 +206,7 @@ public function hasExport($useCache = TRUE)
$hasExport = $this->hasExport;

if ($hasExport === NULL || $useCache === FALSE) {
$hasExport = (bool) $this->getComponent(Export::ID, FALSE);
$hasExport = (bool) $this->getExports(FALSE);
$this->hasExport = $useCache ? $hasExport : NULL;
}

Expand Down Expand Up @@ -361,10 +382,28 @@ public function setOperation(array $operations, $onSubmit)
/**
* @param string $label of exporting file
* @return Export
*
* @deprecated
*/
public function setExport($label = NULL)
{
return new Export($this, $label);
return $this->addExport(new CsvExport($label), CsvExport::CSV_ID);
}

/**
* @param BaseExport $export
* @param string $name Component name
* @return BaseExport
*/
public function addExport(BaseExport $export, $name)
{
$container = $this->getComponent(BaseExport::ID, FALSE);
if (!$container) {
$container = new \Nette\ComponentModel\Container();
$this->addComponent($container, BaseExport::ID);
}
$container->addComponent($export, $name);
return $export;
}

/**
Expand Down
180 changes: 0 additions & 180 deletions src/Components/Export.php

This file was deleted.

Loading

0 comments on commit cc2560e

Please sign in to comment.