Skip to content

Commit

Permalink
use name instance of instance count
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Jul 19, 2023
1 parent 834b05e commit c6452ef
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/ExcelGridFieldExportButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ class ExcelGridFieldExportButton implements
*/
protected $afterExportCallback;

/**
* Static instance counter to allow multiple instances to work together
* @var int
*/
protected static $instances = 0;

/**
* Current instance count
* @var int
*/
protected $instance;

/**
* @param string $targetFragment The HTML fragment to write the button into
* @param array $exportColumns The columns to include in the export
Expand All @@ -95,13 +83,16 @@ public function __construct($targetFragment = "after", $exportColumns = null)
{
$this->targetFragment = $targetFragment;
$this->exportColumns = $exportColumns;
self::$instances++;
$this->instance = self::$instances;
}

public function getActionName()
/**
* @param GridField $gridField
* @return string
*/
public function getActionName($gridField)
{
return 'excelexport_' . $this->instance;
$name = strtolower($gridField->getName());
return 'excelexport_' . $name;
}

/**
Expand All @@ -114,7 +105,7 @@ public function getHTMLFragments($gridField)
'Export to Excel'
);

$name = $this->getActionName();
$name = $this->getActionName($gridField);

$button = new GridField_FormAction(
$gridField,
Expand All @@ -136,7 +127,7 @@ public function getHTMLFragments($gridField)
*/
public function getActions($gridField)
{
return array($this->getActionName());
return array($this->getActionName($gridField));
}

public function handleAction(
Expand All @@ -155,7 +146,7 @@ public function handleAction(
*/
public function getURLHandlers($gridField)
{
return array($this->getActionName() => 'handleExport');
return array($this->getActionName($gridField) => 'handleExport');
}

/**
Expand Down

0 comments on commit c6452ef

Please sign in to comment.