mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 01:34:30 -04:00
Working on export decoration
This commit is contained in:
parent
6d36f57d35
commit
c35716f26e
@ -117,6 +117,8 @@ class PaymentExport extends BaseExport
|
||||
} elseif (array_key_exists($key, $transformed_entity)) {
|
||||
$entity[$key] = $transformed_entity[$key];
|
||||
} else {
|
||||
|
||||
// $entity[$key] = $this->decorator->transform($key, $payment);
|
||||
$entity[$key] = $this->resolveKey($key, $payment, $this->entity_transformer);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class Decorator implements DecoratorInterface{
|
||||
{
|
||||
}
|
||||
|
||||
public function transform(): string
|
||||
public function transform(string $key, mixed $entity): string
|
||||
{
|
||||
return 'Decorator';
|
||||
}
|
||||
@ -110,4 +110,11 @@ class Decorator implements DecoratorInterface{
|
||||
{
|
||||
return $this->entity;
|
||||
}
|
||||
|
||||
public function getKeyPart(int $index, string $key): string
|
||||
{
|
||||
$parts = explode('.', $key ?? '');
|
||||
|
||||
return $parts[$index];
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,5 @@
|
||||
namespace App\Export\Decorators;
|
||||
|
||||
interface DecoratorInterface {
|
||||
public function transform(): string;
|
||||
public function transform(string $key, mixed $entity): string;
|
||||
}
|
||||
|
@ -15,9 +15,16 @@ use App\Models\Payment;
|
||||
|
||||
class PaymentDecorator extends Decorator implements DecoratorInterface{
|
||||
|
||||
public function transform(): string
|
||||
private $key = 'payment';
|
||||
|
||||
public function transform(string $key, $payment): string
|
||||
{
|
||||
$index = $this->getKeyPart(0,$key);
|
||||
|
||||
// match($index)
|
||||
return 'Payment Decorator';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user