Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Return FrozenTime for CakePHP >= 3.3 #1532

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Return FrozenTime for CakePHP >= 3.3 #1532

wants to merge 1 commit into from

Conversation

OneHatRepo
Copy link

CakePHP 3.3 introduced the new FrozenTime class, which new Cake apps default to using, rather than the standard PHP DateTime class. This change follows CakePHP conventions and returns the FrozenTime class.

If you want to make it safer, you can first check for the existence of the Configure class:

                  $datetime = $generator->datetime();
                   if (class_exists('\Cake\Core\Configure') && floatval(\Cake\Core\Configure::version() >= 3.3)) {
                       return new \Cake\I18n\FrozenTime($datetime->format('Y-m-d H:i:s'));
                   }
                   return $datetime;

CakePHP 3.3 introduced the new FrozenTime class, which new Cake apps default to using, rather than the standard PHP DateTime class. This change follows CakePHP conventions and returns the FrozenTime class.
@ppelgrims
Copy link
Contributor

I'm not sure if the check is needed here, wouldn't the dependencies in Cake take care of this? E.g. below version 3.3, it would use the current Faker release? And from 3.3 it would use the next release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants