mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 05:06:37 +00:00
New method for consistent data collection.
This commit is contained in:
@@ -33,6 +33,27 @@ use Log;
|
||||
trait ConvertsDataTypes
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns all data in the request, or omits the field if not set,
|
||||
* according to the config from the request. This is the way.
|
||||
*
|
||||
* @param array $fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAllData(array $fields): array
|
||||
{
|
||||
$return = [];
|
||||
foreach ($fields as $field => $info) {
|
||||
if ($this->has($info[0])) {
|
||||
$method = $info[1];
|
||||
$return[$field] = $this->$method($info[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return date or NULL.
|
||||
*
|
||||
@@ -142,7 +163,7 @@ trait ConvertsDataTypes
|
||||
|
||||
return null;
|
||||
}
|
||||
Log::debug(sprintf('Date object: %s (%s)',$carbon->toW3cString() , $carbon->getTimezone()));
|
||||
Log::debug(sprintf('Date object: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()));
|
||||
|
||||
return $carbon;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user