-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
UnknownDataTableExporterException.php
52 lines (43 loc) · 1.5 KB
/
UnknownDataTableExporterException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* Symfony DataTables Bundle
* (c) Omines Internetbureau B.V. - https://omines.nl/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Omines\DataTablesBundle\Exception;
use Omines\DataTablesBundle\Exporter\DataTableExporterInterface;
/**
* Thrown when a DataTable exporter cannot be found.
*
* @author Maxime Pinot <contact@maximepinot.com>
*/
class UnknownDataTableExporterException extends \Exception
{
/**
* UnknownDataTableExporterException constructor.
*
* @param string $name The name of the DataTable exporter that cannot be found
* @param \Traversable $referencedExporters Available DataTable exporters
*/
public function __construct(string $name, \Traversable $referencedExporters)
{
$format = <<<EOF
Cannot find a DataTable exporter named "%s".
Did you forget to tag the exporter with 'datatables.exporter'?
Referenced DataTable exporters are : %s.
EOF;
parent::__construct(sprintf($format, $name, $this->formatReferencedExporters($referencedExporters)));
}
private function formatReferencedExporters(\Traversable $referencedExporters): string
{
$names = [];
/** @var DataTableExporterInterface $exporter */
foreach ($referencedExporters as $exporter) {
$names[] = sprintf('"%s"', $exporter->getName());
}
return implode(', ', $names);
}
}