Update export.class.php (#31783)

Allow usage of a method param that is not part of the $obj from the sql request. 

The issue I encontered is the usage of order's LibStatut method that required a $mode param that can't be fetched from the sql request obj.

This would be the code for the export declaration : 
		$this->export_special_array[$r] = array(
			'orders.fk_statut'=> [
				'rule' => 'compute',
				'class' => 'Commande',
				'classfile' => '/commande/class/commande.class.php',
				'method' => 'LibStatut',
				'method_params' => ['orders_fk_statut', 'orders_facture', '1'],
			],
		);

We can see that the first two params will come from the $obj, but the third one will be used for it's value (in this case '1').

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Quentin-Seekness 2024-11-12 18:55:56 +01:00 committed by GitHub
parent e63992b779
commit daafa150a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -837,7 +837,7 @@ class Export
$params = [];
if (!empty($item['method_params'])) {
foreach ($item['method_params'] as $paramName) {
$params[] = $obj->$paramName ?? null;
$params[] = $obj->$paramName ?? ($paramName ?? null);
}
}
$value = $tmpObject->$methodName(...$params);