Skip to content

Conversation

@clmntb
Copy link

@clmntb clmntb commented May 29, 2017

Some Form Types were altered for a better integration in the Sylius
Admin Bundle (single_text widget is well handled), this can be removed
during the pull request. Moreover, I removed the limitations on dates as
they were limiting (year after the current year should be allowed, the
widget should not be set to the current date on entity edition).

To be able to use the "days_to_date" functionnality, repositories should
implement a method to check the "days_to_date" key in the configuration
of the DataFetcher, the following code can help :

"""
private function getStartAndEndDates(array $configuration = [])
{
if(array_key_exists('days_to_date', $configuration) and
$configuration['days_to_date'] and
intval($configuration['days_to_date']) > 0){
$now = new \DateTime('now');
$then = new \DateTime('-' .
intval($configuration['days_to_date']) . ' days');
if($then < $configuration['start']){
return [
'start' => $configuration['start']->format('Y-m-d
H:i:s'),
'end' => $now->format('Y-m-d H:i:s'),
];
}
return [
'start' => $then->format('Y-m-d H:i:s'),
'end' => $now->format('Y-m-d H:i:s'),
];
}
return [
'start' => $configuration['start']->format('Y-m-d H:i:s'),
'end' => $configuration['end']->format('Y-m-d H:i:s'),
];
}
"""

clmntb and others added 4 commits May 29, 2017 15:44
timeframe and report only on the N days before the current date.

Some Form Types were altered for a better integration in the Sylius
Admin Bundle (single_text widget is well handled), this can be removed
during the pull request. Moreover, I removed the limitations on dates as
they were limiting (year after the current year should be allowed, the
widget should not be set to the current date on entity edition).

To be able to use the "days_to_date" functionnality, repositories should
implement a method to check the "days_to_date" key in the configuration
of the DataFetcher, the following code can help :

"""
    private function getStartAndEndDates(array $configuration = [])
    {
        if(array_key_exists('days_to_date', $configuration) and
$configuration['days_to_date'] and
intval($configuration['days_to_date']) > 0){
            $now = new \DateTime('now');
            $then = new \DateTime('-' .
intval($configuration['days_to_date']) . ' days');
            if($then < $configuration['start']){
                return [
                    'start' => $configuration['start']->format('Y-m-d
H:i:s'),
                    'end' => $now->format('Y-m-d H:i:s'),
                ];
            }
            return [
                'start' => $then->format('Y-m-d H:i:s'),
                'end' => $now->format('Y-m-d H:i:s'),
            ];
        }
        return [
            'start' => $configuration['start']->format('Y-m-d H:i:s'),
            'end' => $configuration['end']->format('Y-m-d H:i:s'),
        ];
    }
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant