Skip to content

Commit 4289e44

Browse files
committed
Docs for UUID config DI.
1 parent 9fe7672 commit 4289e44

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

en/appendices/5-3-migration-guide.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,10 @@ TestSuite
112112

113113
- ``assertRedirectBack()`` added to assert a successful redirect has been made to the same previous URL.
114114
- ``assertRedirectBackToReferer()`` added to assert a successful redirect has been made to the referer URL.
115+
116+
Utility
117+
-------
118+
119+
- ``Text::uuid()`` now supports configurable UUID generation. You can set a custom
120+
UUID generator using ``Configure::write('Text.uuidGenerator', $closure)`` to
121+
integrate your own UUID generation strategy or third-party libraries.

en/core-libraries/text.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ UUID is a 128-bit string in the format of
9797

9898
Text::uuid(); // 485fc381-e790-47a3-9794-1337c0a8fe68
9999

100+
.. versionadded:: 5.3.0
101+
You can now configure a custom UUID generator using dependency injection.
102+
103+
Starting from CakePHP 5.3.0, you can configure a custom UUID generator by
104+
setting a closure in your configuration::
105+
106+
// In your config/app.php or config/bootstrap.php
107+
use Cake\Core\Configure;
108+
109+
Configure::write('Text.uuidGenerator', function () {
110+
// Return your custom UUID string
111+
return \MyUuidLibrary::generate();
112+
});
113+
114+
This allows you to integrate your own UUID generation strategy or use
115+
third-party UUID libraries. When a custom generator is configured, it will
116+
be used instead of the default UUID generation method.
117+
100118
Simple String Parsing
101119
=====================
102120

0 commit comments

Comments
 (0)